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

Script that sends a file via mailx

Reply to Message Icon

Original Message
Name: UnixNewbie
Date: March 13, 2004 at 06:40:43 Pacific
Subject: Script that sends a file via mailx
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


Report Offensive Message For Removal

Response Number 1
Name: cbailey33
Date: March 13, 2004 at 16:14:51 Pacific
Subject: Script that sends a file via mailx
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 2
Name: WilliamRobertson
Date: March 14, 2004 at 14:43:34 Pacific
Subject: Script that sends a file via mailx
Reply: (edit)

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Script that sends a file via mailx

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software