Solved

Need a small shell script

Posted on 2002-05-18
5
218 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
Comment Utility
err why uuencode it?
0
 

Author Comment

by:bhuey_ling
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks.. it solve my problem  :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now