?
Solved

Need a small shell script

Posted on 2002-05-18
5
Medium Priority
?
228 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 400 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

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…
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…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

741 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