uuencode is not working properly

Hello Everyone,

I'm very new to the shell script. I'm trying to send multiple attachments in unix using uuencode command.

Total I have 3 text files which should be send in mail.

but I'm getting 6 files [ original 3 text files] and 3 files with subject as file name. And the content is

`
end

I'm working on cisco linux. So pls help me out in this..

Awaiting for your prompt responses..

Thanks
Ravi Kiran

What does your code look like?

Hi,

My code is here:

(
for i in /apps/*.txt
   do
      uuencode $i $(basename $i)
   done
) | mailx -s "My Files" ravi.kiran0925@gmail.com

Thanks
Ravi

Hi Franklin,

Thanks for replying on this.. As I'm not aware of anyting in unix.. could you pls guide me or help in resolving this issue..

Thanks
RK

Here's an example I did for folks at work to illustrate sending attachments. I added functionality to do what you are trying to do. This works using ksh on Solaris. Just replace the variables in the constants section. Hope it helps you:

#!/bin/ksh
##
##  mailtest - example to show how to do attachments.
##

# Set constants
typeset -r MAILBODY="This is the body of the e-mail"
typeset -r FILEPATH=/dir1/subdir1
typeset -r FILESPEC=*.sh
typeset -rx SINGLEFILE=set_example.sh
typeset -r MAILADDR=name@domain.com

# convert CR/LF so it will open properly in Outlook.
# only need this if CR/LFs are not being translated properly.
unix2dos -437 -ascii $SINGLEFILE attach.out
if (( $? != 0 ))
  then print "$0: unix2dos failed"
       exit 1
fi

#
# Attach one file.
#
(print $MAILBODY; uuencode attach.out $SINGLEFILE) | \
    mailx -s "mail example 1 attachment" $MAILADDR
if (( $? != 0 ))
  then print "$0: uuencode or mailx failed"
       exit 2
fi

#
# Attach the file twice by specifying explicitly.
#
(print $MAILBODY; uuencode attach.out ${SINGLEFILE}; uuencode attach.out ${SINGLEFILE}) | \
    mailx -s "mail example 2 attachments" $MAILADDR
if (( $? != 0 ))
  then print "$0: uuencode or mailx failed"
       exit 3
fi

#
# Attach multiple files by specifying a filespec.
#
( print $MAILBODY;
for filename in ${FILEPATH}/${FILESPEC}
do
  uuencode $filename $(basename $filename)
done) | mailx -s "multiple attachments via filespec" $MAILADDR
if (( $? != 0 ))
  then print "$0: uuencode or mailx failed"
       exit 4
fi

exit 0

Is it possible you are getting badly formed filenames returned or files with spaces in them from *.txt? Do an ls -l on *.txt and make sure you are getting what you expect.

Hi Gary,

Thanks for posting this. But even this doesn't solve my problem.

I'm still getting those additoinal files with content
`
end

What I noticed is if the attachment have content its attaching the additional file, else not..

Please help me in rectifying this issue..

Thanks
Ravi Kiran.

I'm afraid I'm stumped as to why its not working for you.