Solved

Sending a message that includes a text file to an IMAP server every 30 minutes

Posted on 2000-03-02
5
207 Views
Last Modified: 2013-11-18
I would like to know how to automate and build a script that will send a text file as an email to a user(s) ever 30 minutes.  I have the following simple script that builds a simple text file....

while true
do
processname >> processtxt
sleep 1800
done

I execute this with the nohup option and use the & parameter.
I would now like to mail the processtxt file to an email recipient every 30 minutes.
Help would be greatly appreciated.
BC
0
Comment
Question by:bcornele
5 Comments
 
LVL 21

Accepted Solution

by:
tfewster earned 50 total points
ID: 2579778
How about :

while true
do
  processname > processtxt   #Note, not >>
  mail useraddress < processtxt
  sleep 1800
done

I can't help you much on the mail addressing/routing tho' :(

Hope this helps
0
 

Expert Comment

by:sivaran
ID: 2580117
Try putting the batch in cron tab file and execute the file every 30 minutes
and also put a cron file for sending out the mail.

sivaran
0
 
LVL 1

Expert Comment

by:sereda
ID: 2580157
crontab -e
--- editor pops up
--- add following line:
0,30 * * * * processname | mail user@email
--- close file

And that's it. No need for additional file and script.
0
 

Author Comment

by:bcornele
ID: 2582408
While I am familiar with crontab, I am trying to keep this in a script I can execute from my home directory using the nohup command with the & arg.  I rejected your answer because I needed script coding lines to compliment my existing script.  Thanks. BC
0
 

Author Comment

by:bcornele
ID: 2582416
The pipe of the processtxt clued me in on how to pipe a chunk of data to mailx using the -s option with a subject line.

Here is the final script with your modifications.

while true
do
processname >> processtxt
mailx -s "Subject Line" user@domain.com < processtxt
sleep 1800
done

Thanks for you information and prompt repsponse to my question.
BC
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question