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.

#!/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

Recommended Answers

All 14 Replies

Should i maybe chmod 777 the file before the tar and compress part??

Hey There,

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

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

Hi Mike

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

As well you should be ;)

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

Hi Mike

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

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

$ 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

Hi Mike

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

Cool,

I'll check back.

Best wishes,

Mike

Hi Mike

Well is seemed to go well then all of a sudden one day it decided to do it again :(

begin 644 /var/tmp/aimtmlla-20080709.txt.tar.gz
M'XL("(D)=D@" V%I;71M;&QA+3(P,#@P-S Y+G1X="YT87( U)U;=]LXDH#[
M5?LK^#0[?<ZZ%X4['BF*EMB22"U)V?&^^'B[O3,YD\M,XLQL__LM4#=*E!-3
M@D0PISNV;$7X6 *585"X>G]QY>/'SX\W5!"-%'$_/+R?R\_N?U#\(]2"K\"
MX53:UY0(@E\I4,:IDN0G ,($)UR"_3D((O%]/UWAS[>O+T]?L,EO&B4@Z*OO
M^_S.W+E^=/
MO_WQ&'W^_7FP^G7YQ]^?!]F_/CU_>2P6Z?J[6;S^)EL.[IX^?'MZ>?_YT^JM
MQ<N7YZ>/^&F/T=/7O_[OA\__LI^<+NX>-Y]>O5@6H\?X']_>__/IP_.GE]J'
MC)Y>G@?CV>/B\]>7]Y_^LGH=??[VZ>7YR]^?OKS\81O?>YT^?3QX!U+MO;;@
MB7WY\?GW]T]?5C_(WW_]V^/\Z=/37YX_(L+C\.GEM[]:UO'3^T^/L\]?OSXF
MGWY__]O3R^<O@_"WW^P'/J;?/O[/,[[\@!_V"8'_^?RX_ZM_4ZL!P8!K4(-R
M.IH-?ET\#**H& BIB#!\@-,![%_X8E"4>1S.!W1 ?B%D]==F1NZ^P?<:_)1Y
MEH_#-(@F81$'PS"=!FD8W 1E-GW(\"N^(1JN7M^L?S:*\^0N&,7%M&H/!#)(
M;2@,!DD. _QRC!?[YD>\T#6OXMPPZ(]\Z[S^RY=(RHTP=#"9SF_?X=]K8"HD
M FR 9AZ(S#^&52$V6U01%DY"]-1L)A%@Y7:' WE%&ZPB!;L4DI".<< 8K[
M1861Y.=B+/)L'"9I,,ZSY2*8)?.DC$<;#@6&2,(.NP\Y (Q9<]C^.Y]CG,U&
M<^R^(HPF11"%BZ0,9\$\S*=Q602SQ58T5(+0_&PD>@4D)I0"IU(:YO$=$DVR
M^S ?!6&1A,A3E'$>W"YQ",W*7=<);B2!LZ'H5:"XT5SZ("ER.A2]"A052@NG
MDBHG,1*EXRG^'UA%5$S"=#P)DTJ))OC#*,L761Z629;6&0EP@9_3[,V6C+0+

I think im going to cry, lol

Man,

Too bad. I was hoping that was working.

2 more things:

1. Do you always use the same email client to read your mails? Some only do MIME unless you tell them to do uuencoded also. I think Outlook actually makes you choose one or the other, for some reason.

2. On all the failed mails you get, are they the same size? Just wondering if a mail size limit is clipping the attachment and you're seeing the raw uuencoded format because, although you have the "644 begin" header, your mail doesn't have the end footer

Here's hopin' :)

BTW, mpack and munpack (that I referenced a few posts back in this thread to MIME encoding/decoding as opposed to uu

, Mike

/usr/bin/uuencode $file3 $file3 | /usr/bin/mailx -m -s "Report for COB $YESTERDAY" "joe.blogs@hotmail.com" try like this

Try this:

echo "\
Subject: My Email Subject at date \"+%m/%d/%Y %r UTC\"
MIME-Version: 1.0
Content-type: multipart/mixed; boundary="^A^A^A^A^A"
Content-Transfer-Encoding: 7bit

--^A^A^A^A^A
Content-Type: text/plain; charset=US-ASCII; name="BDY.TXT"
Content-Disposition: inline; filename="BDY.TXT"
Content-Transfer-Encoding: 7bit

My Email Subject at date \"+%m/%d/%Y %r UTC\"

--^A^A^A^A^A
Content-Type: text/plain; charset=US-ASCII; name="ZIP_FILE"
Content-Disposition: attachment; filename="ZIP_FILE"
Content-Transfer-Encoding: 7bit

" > /tmp/ZIP_FILE

cat /tmp/MySourceZipFile >> /tmp/ZIP_FILE
echo "
--^A^A^A^A^A--" >> /tmp/ZIP_FILE

/usr/sbin/sendmail "GodSend@Heaven.godcom" < /tmp/ZIP_FILE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.