Solved

Need a small shell script

Posted on 2002-05-18
5
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

717 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