943,699 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jun 27th, 2008
0

begin 644 msg from script sending file

Expand Post »
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=.&#9LP+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)
  1. #!/bin/ksh
  2.  
  3. #set -o xtrace
  4.  
  5. DTE=`date +%Y%m%d`
  6.  
  7. TPATH="/apps/prod-dom/prod/data/formatter/MO_app/archive"
  8. ###############################################################################
  9. #Checking Base Directory available, abort if errors
  10. ###############################################################################
  11. if [[ ! -r $TPATH ]]
  12. then
  13. print "Error - Base directory does not exist or is unreadable:"
  14. print " "$TPATH
  15. exit -1
  16. fi
  17.  
  18. ###############################################################################
  19. # Checking for the required file
  20. # Sleeps for 10 minutes and rechecks for incoming file
  21. ###############################################################################
  22.  
  23. print "todays date is "$DTE
  24. TZ=GMT+24
  25. DTE1=`date +%Y%m%d`
  26. file1=aimtl-$DTE1.txt
  27.  
  28. FILE_THERE=NO
  29.  
  30. while [ $FILE_THERE != YES ]
  31. do
  32. if [ -e $TPATH/$file1 ]
  33. then
  34. print "The file exist"
  35. print "Sleeping for 10 minutes zzzzz"
  36. sleep 600
  37. cp $TPATH/$file1 /var/tmp
  38. FILE_THERE=YES
  39. else
  40. print $TPATH/$file1
  41. print "File printed above with the '.txt' at the end is missing.Sleeping & Rechecking $TPATH"
  42. sleep 600
  43. fi
  44. done
  45.  
  46.  
  47. #Zip the file
  48.  
  49. cd /var/tmp
  50.  
  51. file=/var/tmp/$file1.tar
  52.  
  53. /usr/bin/tar -cvf $file $file1
  54.  
  55. compress $file
  56.  
  57. sleep 120
  58.  
  59. TZ=GMT+24
  60. YESTERDAY=`/usr/bin/date +"%a %d %h %Y"`
  61.  
  62. /usr/bin/uuencode $file.Z $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
  63.  
  64. sleep 60
  65. rm -f $file
  66. rm -f $file.Z
  67. rm -f /var/tmp/$file1
Last edited by Narue; Jun 28th, 2008 at 12:42 pm. Reason: Added code tags
Reputation Points: 10
Solved Threads: 0
Light Poster
skelly16 is offline Offline
34 posts
since Aug 2007
Jun 27th, 2008
0

Re: begin 644 msg from script sending file

Should i maybe chmod 777 the file before the tar and compress part??
Reputation Points: 10
Solved Threads: 0
Light Poster
skelly16 is offline Offline
34 posts
since Aug 2007
Jun 28th, 2008
0

Re: begin 644 msg from script sending file

Hey There,

You may just need to remove one argument from your uuencode line so

Quote ...
/usr/bin/uuencode $file.Z $file.Z | /usr/bin/mailx -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com"
becomes

Quote ...
/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:

Quote ...
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 28th, 2008 at 12:13 am. Reason: typo
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jun 28th, 2008
0

Re: begin 644 msg from script sending file

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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jun 28th, 2008
0

Re: begin 644 msg from script sending file

Hi Mike

I tried the below but it seems to just hang etc.

Quote ...
/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...
Reputation Points: 10
Solved Threads: 0
Light Poster
skelly16 is offline Offline
34 posts
since Aug 2007
Jun 28th, 2008
0

Re: begin 644 msg from script sending file

As well you should be

Just kidding. My original line was flawed because I assumed standard input for uuencode

Quote ...
uuencode outputname
which would work for

Quote ...
uuencode outputname <inputname
or

Quote ...
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:

Quote ...
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

Quote ...
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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jun 28th, 2008
0

Re: begin 644 msg from script sending file

Hi Mike

Here you go

Quote ...
+ + 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
Reputation Points: 10
Solved Threads: 0
Light Poster
skelly16 is offline Offline
34 posts
since Aug 2007
Jul 1st, 2008
0

Re: begin 644 msg from script sending file

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

Quote ...
$ 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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jul 2nd, 2008
0

Re: begin 644 msg from script sending file

Hi Mike

Im going to try this for a week and see if it resolves the issue, using tar and gzip only.

Quote ...
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
Reputation Points: 10
Solved Threads: 0
Light Poster
skelly16 is offline Offline
34 posts
since Aug 2007
Jul 3rd, 2008
0

Re: begin 644 msg from script sending file

Cool,

I'll check back.

Best wishes,

Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: supression script
Next Thread in Shell Scripting Forum Timeline: if statement question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC