Operating System - HP-UX
1752416 Members
6442 Online
108788 Solutions
New Discussion юеВ

Re: How to attach the file as an attachment through automated unix script.

 
Narendra Uttekar
Regular Advisor

How to attach the file as an attachment through automated unix script.

Hi,
I want to attach the files in directory /Test/Out whenever it is copied to backup directory i.e. when the script is schedule to run. Please find the below script for copying files to backup directory, Please help me to modify this script to send me the files as an attachment in the automated e-mail which i am getting at the schedule script run.

#!/bin/ksh
cd /Test/Out
file=$(ls *)
for x in $file
do
cp $x /Test/backup/$x
done
mailx -s"FTP File" narendra.uttekar@xxxxx.com < /tmp/log/file.log

Thanks,
Narendra
3 REPLIES 3
Pete Randall
Outstanding Contributor

Re: How to attach the file as an attachment through automated unix script.

Try a Google search on "mail attachment +site:itrc.hp.com". That will give many, many threads on this particular topic.


Pete

Pete
Tim Nelson
Honored Contributor

Re: How to attach the file as an attachment through automated unix script.

#!/bin/ksh
cd /Test/Out
file=$(ls *)
for x in $file
do
cp $x /Test/backup/$x
done
uuecode /tmp/log/file.log file.log|mailx -s "FTP File" narendra.uttekar@xxxxx.com
Narendra Uttekar
Regular Advisor

Re: How to attach the file as an attachment through automated unix script.

Hi Tim,
Thanks for the reply...i have modified the script as below as per your suggestion...
#!/bin/ksh
cd /Test/Out
file=$(ls *)
for x in $file
do
cp $x /Test/backup/$x
done
uuencode /Test/Out/$x $x|mailx -m -s "FTP File" narendra.uttekar@xxxxx.com < /tmp/log/file.log
With this script i am able to get the message body text...But if i use uuencode /Test/Out/$x $x|mailx -m -s "FTP File" narendra.uttekar@xxxxx.com then i am able to get the attachment. But i want both message body text and attachment all together.

Thanks,
Narendra