I am supposed to write a script that sends a file (using mailx), that I created, to my professor. This is a killer, I can't seem to figure out how to solve this problem.
Additionally, if anybody could let me know how to include the date (using the date command) on the subject line that would be great.
I put the date in back quotes. (see below)
$ mailx username@yahoo.com
Subject: `date +"%d-%m-%Y %R"`
.
EOT
but it arrives in my subject line exactly as printed above.
Subject: `date +"%d-%m-%Y %R"`
-----------------------------/
Try putting this within your script.
Echo the body of your messeage to /usr/ucb/Mail.
echo "Body of Message" | /usr/ucb/Mail -s "`date +%d-%m-%Y %R`" username@yahoo.com
You can also put a list of names in a file (/nitely/maillist). Then replace the <username@yahoo> with (and remember the back quotes) `cat /nitely/maillist`
-----------------------------/
If you can use ksh, $(expr) is better than `expr`.
Expressions like this can only be evaluated by the shell, not within applications.
mailx -s $(date)
etc should work.
I don't have mailx to test right now, but you could try something like
mailx -s $(date) < yourfile.txt
-----------------------------/
Any shell script that automatically mails the desired address. What are the required parameters necessary to write such a script.
cat your_file | mailx -s"test" you@example.com
Or you can use this:
mail -s "Your Subject Line" you@domain.com < your_file
sendmail may also be available on your system.
Use the man pages for either to get more detail.
Quick Links:
Do you have
a UNIX Question?
Unix Home: Unix System Administration
Hints and Tips