bhuey_ling
asked on
Need a small shell script
Hi
I have problem to sent a mail after i done my rsync cron job. I don't want to receive a mail after each rsync done by using " .. | mail -s "" hl@abc.com. So, I log the message to a logfile. But I faced another problem.
ex of my code:
-------------------------- ---------- ---------- ----
#!/bin/sh
# start rsync test source and test list
set LOG=/tmp/rsync.$$.`date|aw k '{printf "%s\n", $4}'`.txt
echo $LOG
echo "rsync /fs1/projA:" > $LOG
/usr/bin/rsync -Lpgtrzv --numeric-ids /afs/projA/
/fs2/projA/ >> $LOG
echo "" >> $LOG
echo "rsync /fs1/projB/:" >> $LOG
/usr/bin/rsync -Lpgtrzv --numeric-ids /afs/projB/ /fs3/projB >> $LOG
#... more files to sync
(uuencode $LOG $LOG;) | mail -s "Rsync Message" hl@abc.com
# All done, exit ok
exit 0
-------------------------- ---------- ---------
From this code, I get an unformated attachment txt file when i open directly from outlook. It is hard to read.
Is there any way to:
1. print the content of the log file into the mail? Then i can read directly from my mailbox instead of open the attachement.
or
2. I can read the file in a correct file format when i open thru outlook?
thanks
hl
I have problem to sent a mail after i done my rsync cron job. I don't want to receive a mail after each rsync done by using " .. | mail -s "" hl@abc.com. So, I log the message to a logfile. But I faced another problem.
ex of my code:
--------------------------
#!/bin/sh
# start rsync test source and test list
set LOG=/tmp/rsync.$$.`date|aw
echo $LOG
echo "rsync /fs1/projA:" > $LOG
/usr/bin/rsync -Lpgtrzv --numeric-ids /afs/projA/
/fs2/projA/ >> $LOG
echo "" >> $LOG
echo "rsync /fs1/projB/:" >> $LOG
/usr/bin/rsync -Lpgtrzv --numeric-ids /afs/projB/ /fs3/projB >> $LOG
#... more files to sync
(uuencode $LOG $LOG;) | mail -s "Rsync Message" hl@abc.com
# All done, exit ok
exit 0
--------------------------
From this code, I get an unformated attachment txt file when i open directly from outlook. It is hard to read.
Is there any way to:
1. print the content of the log file into the mail? Then i can read directly from my mailbox instead of open the attachement.
or
2. I can read the file in a correct file format when i open thru outlook?
thanks
hl
err why uuencode it?
ASKER
I will get a NULL message body and not attachment without using (uuencode .....;)|mail ....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
either mail the file as text (as suggested before),
or add a valide MIME header to the uuencoded text,
or use a MUA which can handle it without MIME header ;-)
or add a valide MIME header to the uuencoded text,
or use a MUA which can handle it without MIME header ;-)
ASKER
thanks.. it solve my problem :)