Solved

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

Posted on 2000-03-02
5
188 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 20

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now