Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail attatchments from shell prompt????

Status
Not open for further replies.

KarveR

MIS
Dec 14, 1999
2,065
GB
Hi all, I'm a newbie here and also to SCO UNIX, (about a year now) and I have a problem ....<br>
<br>
Is it possible to send attatchments to e-mail, i.e a html or xls file along with a mail message from the shell prompt?<br>
Can this be done, if so would one of you kind people let me know how please, <br>
<br>
thanks in advance.<br>
<br>
KarveR
 
Here's a dodgy (ie, quick, dirty, and untested :) bit of shell script that may do what you want. I know it's not quite what you asked for, but it may point you in the right direction. (Backslashes inserted to escape newlines for readability.)<br>
<br>
FILE_TO_SEND=/path/to/my/file<br>
SUBJECT=&quot;My subject line&quot;<br>
MESSAGE=&quot;My message to whomever I'm sending the message to.&quot;<br>
RECIPIENT=<A HREF="mailto:somebody@somewhere.com">somebody@somewhere.com</A><br>
<br>
echo &quot;${MESSAGE}\n\n----- Cut message below and save contents for uudecode \<br>
-----\n\n`uuencode ${FILE_TO_SEND} ${FILE_TO_SEND}`\n\n-----Uuencoded text ends above -----&quot; ¦ mailx -s &quot;${SUBJECT}&quot; ${RECIPIENT}<br>
<br>
Hope this helps, some. It assumes that the recipient has the ability to save the message, cut out the uuencoded text, and the run uudecode against it.<br>
<br>
Alternatively, if it's a text file, replace the &quot;uuencode&quot; bit with something like `cat my_file`.<br>

 
Many thanks, sorry it took a while to get back to you.<br>
<br>
This is perfect for what I need, and works a treat.<br>
<br>
To be a pain tho, can you suggest how i would do this with multiple files for the one message?<br>
<br>
Thanks again,<br>
Kev
 
No problem - glad to be of help :) And sorry for the late reply myself, but I've been afk for a few days :(<br>
<br>
Just put a for loop around the bit of code doing the uucp. ie,<br>
<br>
FILES=&quot;file1 file2 file3 file4 file5&quot;<br>
<br>
for FILE_TO_SEND in ${FILES}<br>
do<br>
echo &quot;${MESSAGE}\n\n----- Cut message below and save contents for uudecode \<br>
----\n\n`uuencode ${FILE_TO_SEND} ${FILE_TO_SEND}`\n\n-----Uuencoded text ends above -----&quot; ¦<br>
mailx -s &quot;${SUBJECT}&quot; ${RECIPIENT}<br>
<br>
done<br>
<br>
Should do what you require :)
 
Many thanks, with only slight mods, I am now E-Mailing Our customer reports out from cron (all 66 of them and rising) saving me a huge chunk of Monday morning for sleeping in :)<br>
<br>
Sorry for the delay again, but this Y2K lark is turning into a drag!<br>
<br>
Still, Happy holidays and thanks again,<br>
<br>
Kev
 
Blimey, 2 years on and a little wiser, also for anyone who wants to do this:
vi msg
insert all your message

uuencode filename filename |mail -s&quot;Subject&quot; recipient@place.com < msg I can't have sent that email, it says from Superuser.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top