Solved

Need a small shell script

Posted on 2002-05-18
5
220 Views
Last Modified: 2010-04-21
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|awk '{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
0
Comment
Question by:bhuey_ling
5 Comments
 
LVL 5

Expert Comment

by:ecw
ID: 7020301
err why uuencode it?
0
 

Author Comment

by:bhuey_ling
ID: 7020471
I will get a NULL message body and not attachment without using (uuencode .....;)|mail ....
0
 
LVL 38

Accepted Solution

by:
yuzh earned 100 total points
ID: 7020606
Your logfile is a text file, why don't you just do:

mailx -s"Rsync Message" your-email-add < $LOG

or

mail youremail < $LOG

instead of uuencode, with uuencode you have to read it on a UNIX/Linux box with uudecode.

The above example allowing to put your logfile in your email body, you can use whatever email client to read it


0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7022464
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 ;-)
0
 

Author Comment

by:bhuey_ling
ID: 7022863
thanks.. it solve my problem  :)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question