Computing.Net > Forums > Unix > Script that sends a file via mailx

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script that sends a file via mailx

Reply to Message Icon

Name: UnixNewbie
Date: March 13, 2004 at 06:40:43 Pacific
OS: Win ME
CPU/Ram: 950 Mhz 128 MBq
Comment:

Hi,

If anybody could help me with this one I would really appreciate it.
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"`


Thank you,
UnixNewbie



Sponsored Link
Ads by Google

Response Number 1
Name: cbailey33
Date: March 13, 2004 at 16:14:51 Pacific
Reply:

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`

CAB


0

Response Number 2
Name: WilliamRobertson
Date: March 14, 2004 at 14:43:34 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Script that sends a file via mailx

shell script to send a file thru FT www.computing.net/answers/unix/shell-script-to-send-a-file-thru-ft/6428.html

shell script that reads a file www.computing.net/answers/unix/shell-script-that-reads-a-file/4967.html

Unix shell script for opening a file and www.computing.net/answers/unix/unix-shell-script-for-opening-a-file-and/3452.html