| | |
begin 644 msg from script sending file
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2007
Posts: 34
Reputation:
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.
Shell Scripting Syntax (Toggle Plain Text)
#!/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 12:42 pm. Reason: Added code tags
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
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"
•
•
•
•
/usr/bin/uuencode $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
•
•
•
•
tar -czf $file $file1/usr/bin/uuencode| /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
Best wishes,
Mike
Last edited by eggi; Jun 28th, 2008 at 12:13 am. Reason: typo
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
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!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Aug 2007
Posts: 34
Reputation:
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"
Very confused buddy...
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
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
•
•
•
•
uuencode outputname <inputname
•
•
•
•
cat inputname|uuencode outputname
•
•
•
•
uuencode inputname outputname
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
Sorry 'bout that!
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Aug 2007
Posts: 34
Reputation:
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: 399
Reputation:
Solved Threads: 47
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
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!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Aug 2007
Posts: 34
Reputation:
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: 399
Reputation:
Solved Threads: 47
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!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: supression script
- Next Thread: if statement question
| Thread Tools | Search this Thread |





