Unix : Script that sends a file
via mailx
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
but it arrives in my subject line exactly as printed above. Subject: `date +"%d-%m-%Y %R"` -----------------------------/ Try putting this within your script.
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:
sendmail may also be available on your system.
See Also
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|