Solved

Need a small shell script

Posted on 2002-05-18
5
221 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix Command -- Challenging  question 7 95
Write an app 10 70
Install MySQL 5.6 and PHP on Centos Linux 6 136
Writing a UNIX script menu allowing for multiple options. 5 85
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
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.:

789 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