Find the answer to your Linux question:
Results 1 to 4 of 4
I have been trying to figure this out but can't seem to do it. I need a way to have a file emailed to me nightly. I figured out how ...
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    3

    Script to email me a file nightly

    I have been trying to figure this out but can't seem to do it.

    I need a way to have a file emailed to me nightly. I figured out how to do this on logs, diskusage and tons of others but can't seem to figure it out.


    basically I file that generates nightly that is called town13000.txt (basically a town name with the juliean date). I normally just go in and get the file and then do what I need to do with it.

    There has got to be a way to make a script or program or whatever that will grab the file and then email or ftp it to me. what I am running into is the file name changes every day. Its the juliean date, so today town13000.txt tommorrow town13100.txt, town13200.txt and so on.

    I can't figure out how to have the file backup when the file name changes every day. I have been told there are scripts that can follow along but I can't seem to figure out how you to do this.

  2. #2
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73
    Hello,

    let us split the problem onto several parts:
    1) To send file from script, check "sendmail"
    2) To do this regularly, check "at" (add your script name there)
    Frankly speaking I did not understand on what step You have a problem.

  3. #3
    Just Joined!
    Join Date
    May 2007
    Posts
    3
    I don't have a script that will work with the file or at least don't know how to create one.

    baiscally here is what happens.

    at 12:00 a.m. on 5-10-07 a file is genereated called town13000.txt

    at 12:00 a.m. on 5-11-07 a file is generated called town13100.txt

    at 12:00 a.m. on 5-12-07 a file is generated called town13200.txt

    these files are all located in /home/cdr/2007 where basically all my files for the year are located.

    I would like to make or find a script that will send the newly generated file to my email nightly.

    how would I configure sendmail to send a different named file every time and then schedule it to run every night.

    so every day I would receive an email with the 1 text file I need and not have to dig through the whole years files to find the 1 text file I need.

  4. #4
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73
    Hello.

    1. Create the script "MyScript" and give it execution permission (chmod u+x MyScript),
    Code:
    MyFile=GenerateFileName();
    # Write yourself the function GenerateFileName() here.
    # Example: MyFile=town`date +%F` generates e.g. "town2007-05-11" for today.
    uuencode -m $MyFile | sendmail  MyMail@MyProvider.com
    2. Open the file /etc/crontab and add there
    Code:
    0 0 * * * /full/path/to/MyScript
    ("Run the script at 0:00 everyday")

    Hope this gives You a hint what to do. See man pages for all commands for more details.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •