•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 397,582 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,164 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 812 | Replies: 12
![]() |
•
•
Join Date: Aug 2007
Posts: 27
Reputation:
Rep Power: 2
Solved Threads: 0
Hi All
Anyway of resolving this issue.
I have created a script which works properly only issue is occasionaly when the tar.Z file is emailed to me i get this message this only happens sometimes??
begin 644 /var/tmp/aimtl-20080626.txt.tar.Z
M'YV08=*TH=.	LP+63 @($#A@T9-ES0P4,'@,6+&#-JW,BQH\>/( $L7&B#
M!@V1,&+ H $1)0R%-6"@E!$CQ@T;,6C,D &@)HP9,60HC%'#!DJB,&KPE!FR
MJ=.G4*-JK#.'3A@Y*.O@4)B4I]2,;\CDF3.G3)ZO&4>FE%'#Y4BC:./*G4NW
M;MTI5*9\H2(G#)DR7Y(022#DS9LU@0</J2-'3ADW8_)\&1*V3 *^?@%3R0/'
M\I,[;LK(^3(%BI,$GT./9E($-6C17YY426 E#)LZ8>BD>>-F+V?+4^@X#M,F
end
Here is my script i have to use tar and compress by the way.
Anyway of resolving this issue.
I have created a script which works properly only issue is occasionaly when the tar.Z file is emailed to me i get this message this only happens sometimes??
begin 644 /var/tmp/aimtl-20080626.txt.tar.Z
M'YV08=*TH=.	LP+63 @($#A@T9-ES0P4,'@,6+&#-JW,BQH\>/( $L7&B#
M!@V1,&+ H $1)0R%-6"@E!$CQ@T;,6C,D &@)HP9,60HC%'#!DJB,&KPE!FR
MJ=.G4*-JK#.'3A@Y*.O@4)B4I]2,;\CDF3.G3)ZO&4>FE%'#Y4BC:./*G4NW
M;MTI5*9\H2(G#)DR7Y(022#DS9LU@0</J2-'3ADW8_)\&1*V3 *^?@%3R0/'
M\I,[;LK(^3(%BI,$GT./9E($-6C17YY426 E#)LZ8>BD>>-F+V?+4^@X#M,F
end
Here is my script i have to use tar and compress by the way.
#!/bin/ksh
#set -o xtrace
DTE=`date +%Y%m%d`
TPATH="/apps/prod-dom/prod/data/formatter/MO_app/archive"
###############################################################################
#Checking Base Directory available, abort if errors
###############################################################################
if [[ ! -r $TPATH ]]
then
print "Error - Base directory does not exist or is unreadable:"
print " "$TPATH
exit -1
fi
###############################################################################
# Checking for the required file
# Sleeps for 10 minutes and rechecks for incoming file
###############################################################################
print "todays date is "$DTE
TZ=GMT+24
DTE1=`date +%Y%m%d`
file1=aimtl-$DTE1.txt
FILE_THERE=NO
while [ $FILE_THERE != YES ]
do
if [ -e $TPATH/$file1 ]
then
print "The file exist"
print "Sleeping for 10 minutes zzzzz"
sleep 600
cp $TPATH/$file1 /var/tmp
FILE_THERE=YES
else
print $TPATH/$file1
print "File printed above with the '.txt' at the end is missing.Sleeping & Rechecking $TPATH"
sleep 600
fi
done
#Zip the file
cd /var/tmp
file=/var/tmp/$file1.tar
/usr/bin/tar -cvf $file $file1
compress $file
sleep 120
TZ=GMT+24
YESTERDAY=`/usr/bin/date +"%a %d %h %Y"`
/usr/bin/uuencode $file.Z $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
sleep 60
rm -f $file
rm -f $file.Z
rm -f /var/tmp/$file1 Last edited by Narue : Jun 28th, 2008 at 11:42 am. Reason: Added code tags
•
•
Join Date: Oct 2007
Posts: 264
Reputation:
Rep Power: 1
Solved Threads: 26
Hey There,
You may just need to remove one argument from your uuencode line so
becomes
you can also user tar and gzip (if you have the Gnu version of tar, use the -z flag) to shorten it up a bit:
Hope I'm not completely off the mark here.
Best wishes,
Mike
You may just need to remove one argument from your uuencode line so
•
•
•
•
/usr/bin/uuencode $file.Z $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
becomes
•
•
•
•
/usr/bin/uuencode $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
you can also user tar and gzip (if you have the Gnu version of tar, use the -z flag) to shorten it up a bit:
•
•
•
•
tar -czf $file $file1/usr/bin/uuencode| /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
Hope I'm not completely off the mark here.
Best wishes,
Mike
Last edited by eggi : Jun 27th, 2008 at 11:13 pm. Reason: typo
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
•
•
Join Date: Oct 2007
Posts: 264
Reputation:
Rep Power: 1
Solved Threads: 26
Oh, yes,
Also, the
Begin 664
line is normal output from uuencode, so if you're just piping the output to a mail program instead of the terminal, this makes sense, too, and shouldn't be an exception. That's interesting.
Thanks,
Mike
Also, the
Begin 664
line is normal output from uuencode, so if you're just piping the output to a mail program instead of the terminal, this makes sense, too, and shouldn't be an exception. That's interesting.
Thanks,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
•
•
Join Date: Aug 2007
Posts: 27
Reputation:
Rep Power: 2
Solved Threads: 0
Hi Mike
I tried the below but it seems to just hang etc.
Also i cant use your other suggestion as it slightly alters the columns in the data thats why ive not used gzip. Its very strange though, as i only get this message now and then but because im testing this in development i want to make sure i never get this message when emailing out and only the tar file sent etc.
Very confused buddy...
I tried the below but it seems to just hang etc.
•
•
•
•
/usr/bin/uuencode $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
Also i cant use your other suggestion as it slightly alters the columns in the data thats why ive not used gzip. Its very strange though, as i only get this message now and then but because im testing this in development i want to make sure i never get this message when emailing out and only the tar file sent etc.
Very confused buddy...
•
•
Join Date: Oct 2007
Posts: 264
Reputation:
Rep Power: 1
Solved Threads: 26
As well you should be 
Just kidding. My original line was flawed because I assumed standard input for uuencode
which would work for
or
only works if STDIN is being piped to uuencode (thinking ahead to my next solution before I typed). Otherwise your way:
is correct.
Sorry about that
BTW, since you only get the strange output once in a while, can you do a run of this with the "set -o xtrace" line uncommented.
ANother thing I notice now, is your
line. You should be able to remove that because your script shouldn't move passed the "compress" until it's done with that command.
Sorry 'bout that!
Best wishes,
Mike

Just kidding. My original line was flawed because I assumed standard input for uuencode
•
•
•
•
uuencode outputname
which would work for
•
•
•
•
uuencode outputname <inputname
or
•
•
•
•
cat inputname|uuencode outputname
only works if STDIN is being piped to uuencode (thinking ahead to my next solution before I typed). Otherwise your way:
•
•
•
•
uuencode inputname outputname
is correct.
Sorry about that

BTW, since you only get the strange output once in a while, can you do a run of this with the "set -o xtrace" line uncommented.
ANother thing I notice now, is your
•
•
•
•
sleep 120
line. You should be able to remove that because your script shouldn't move passed the "compress" until it's done with that command.
Sorry 'bout that!
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
•
•
Join Date: Aug 2007
Posts: 27
Reputation:
Rep Power: 2
Solved Threads: 0
Hi Mike
Here you go
Here you go
•
•
•
•
+ + date +%Y%m%d
DTE=20080628
+ TPATH=/apps/prod-dom/prod/data/formatter/MO_app/archive
+ [[ ! -r /apps/prod-dom/prod/data/formatter/MO_app/archive ]]
+ print todays date is 20080628
todays date is 20080628
+ TZ=GMT+24
+ + date +%Y%m%d
DTE1=20080627
+ file1=aimtl-20080627.txt
+ FILE_THERE=NO
+ [ NO != YES ]
+ [ -e /apps/prod-dom/prod/data/formatter/MO_app/archive/aimtl-20080627.txt ]
+ print The file exist
The file exist
+ print Sleeping for 10 minutes zzzzz
Sleeping for 10 minutes zzzzz
+ sleep 600
+ cp /apps/prod-dom/prod/data/formatter/MO_app/archive/aimtl-20080627.txt /var/tmp
+ FILE_THERE=YES
+ [ YES != YES ]
+ cd /var/tmp
+ chmod 777 aimtl-20080627.txt
+ file=/var/tmp/aimtl-20080627.txt.tar
+ /usr/bin/tar -cvf /var/tmp/aimtl-20080627.txt.tar aimtl-20080627.txt
a aimtl-20080627.txt 35350K
+ compress /var/tmp/aimtl-20080627.txt.tar
+ TZ=GMT+24
+ + /usr/bin/date +%a %d %h %Y
YESTERDAY=Fri 27 Jun 2008
+ /usr/bin/mailx -s Report for COB Fri 27 Jun 2008 joe.blogs@hotmail.com
+ /usr/bin/uuencode /var/tmp/aimtl-20080627.txt.tar.Z /var/tmp/aimtl-20080627.txt.tar.Z
+ sleep 60
+ rm -f /var/tmp/aimtl-20080627.txt.tar
+ rm -f /var/tmp/aimtl-20080627.txt.tar.Z
+ rm -f /var/tmp/aimtl-20080627.txt
+ exit 0
•
•
Join Date: Oct 2007
Posts: 264
Reputation:
Rep Power: 1
Solved Threads: 26
Hey There,
This isn't exactly what you're doing - I cut corners on the file (so it wouldn't take up too much space) and gzipped instead of compressed, but this is basically what you're piping to mailx. It may be that the characters in the attachment are causing you issues, since it's sent as plaintext
Unfortunately, if that's the case, you're stuck because uuencode will always come out that way.
Check this program (mpack) out, which sends the mails as actual attachments (or at least is more standardized) and see if that fixes the issue. Otherwise, what happens to you sometimes, should actually be happening all the time, which is another mystery in and of itself. Do you have an example of when you don't get an email with the uuencode BEGIN line followed by the contents? It may have to do with the mail reader you're using as well.
ftp://ftp.andrew.cmu.edu/pub/mpack/
Best wishes,
Mike
This isn't exactly what you're doing - I cut corners on the file (so it wouldn't take up too much space) and gzipped instead of compressed, but this is basically what you're piping to mailx. It may be that the characters in the attachment are causing you issues, since it's sent as plaintext
•
•
•
•
$ uuencode aimtl-20080627.txt.tar.gz aimtl-20080627.txt.tar.gz|cat
begin 644 aimtl-20080627.txt.tar.gz
M'XL("/BO:4@``V%I;71L+3(P,#@P-C(W+G1X="YT87(`[<Y!"H,P$(7A'"47
MJ$PF:>(IO(.++`JI@DVAQS=*=^).7/T?`P]FWF+&U[N6AXKT$C5U]5?-Y:2)
M(6SITC/NV6;?_QGGQ*O7E+P8<5Y;W<KUKQQ]/W5<K#6YE#PM><HGO6$^/0$`
7````````````````<+<5/2(I9P`H````
`
end
Unfortunately, if that's the case, you're stuck because uuencode will always come out that way.
Check this program (mpack) out, which sends the mails as actual attachments (or at least is more standardized) and see if that fixes the issue. Otherwise, what happens to you sometimes, should actually be happening all the time, which is another mystery in and of itself. Do you have an example of when you don't get an email with the uuencode BEGIN line followed by the contents? It may have to do with the mail reader you're using as well.
ftp://ftp.andrew.cmu.edu/pub/mpack/
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
•
•
Join Date: Aug 2007
Posts: 27
Reputation:
Rep Power: 2
Solved Threads: 0
Hi Mike
Im going to try this for a week and see if it resolves the issue, using tar and gzip only.
Im going to try this for a week and see if it resolves the issue, using tar and gzip only.
•
•
•
•
cd /var/tmp
chmod 777 $file1
file=/var/tmp/$file1.tar
/usr/bin/tar -cvf $file $file1
#compress $file
gzip $file
file3=/var/tmp/$file1.tar.gz
TZ=GMT+24
YESTERDAY=`/usr/bin/date +"%a %d %h %Y"`
/usr/bin/uuencode $file3 $file3 | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
sleep 60
rm -f $file
rm -f $file3
rm -f /var/tmp/$file1
exit 0
•
•
Join Date: Oct 2007
Posts: 264
Reputation:
Rep Power: 1
Solved Threads: 26
Cool,
I'll check back.
Best wishes,
Mike
I'll check back.
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
Other Threads in the Shell Scripting Forum
- Previous Thread: supression script
- Next Thread: if statement question


Linear Mode