uuencode is not working properly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting uuencode is not working properly
# 1  
Old 07-21-2011
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
# 2  
Old 07-21-2011
What does your code look like?
# 3  
Old 07-22-2011
Hi,

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

Thanks
Ravi

Last edited by Franklin52; 07-22-2011 at 02:06 PM.. Reason: Please use code tags for data and code samples, thank you
# 4  
Old 07-27-2011
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
# 5  
Old 07-27-2011
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:
Code:
#!/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.

Last edited by gary_w; 07-27-2011 at 11:58 AM.. Reason: Added thought of why errors might be happening
# 6  
Old 07-28-2011
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.
# 7  
Old 07-28-2011
I'm afraid I'm stumped as to why its not working for you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Uuencode for mail attachments not working

Hi, I'm trying to send mail with attachments using uuencode, but it doesn't work. Command (also tried with mailx): uuencode testfile testfile | mail emailadress The email I get doesn't have an attachment, and has this in the message body: begin 664 testfile %=&5S=`H` ` end ... (4 Replies)
Discussion started by: Subbeh
4 Replies

2. Shell Programming and Scripting

Join not working properly

I want to join two files , with file 1 col 3 and file 2 col 1 as key. The join command is erratic for some reason. File 2 is a master file having all the names, and file 1 has some values. I want to add the names from fil2 in file 1. If I use the original master file, some output is missing. ... (16 Replies)
Discussion started by: ritakadm
16 Replies

3. Red Hat

sudo is not working properly

This is the first time for using sudo for me. # visudo ## Allows people in group admin to run all commands %admin ALL=(ALL) ALL # groupadd admin # useradd temp # usermod -a -G admin temp # id temp uid=506(temp) gid=506(temp) groups=506(temp),507(admin) # #sudo... (5 Replies)
Discussion started by: getrue
5 Replies

4. Shell Programming and Scripting

uuencode not working for multiple files

Hi, I have gone through the other related post but are of no help for me I am sending multiple files as attachement. The first file comes fine as an attachement but the other files are coming as binary. For people with older version of email software they can see all attachements but... (1 Reply)
Discussion started by: pinnacle
1 Replies

5. UNIX for Advanced & Expert Users

Sendmail is not working properly

Hi All, Can any one help me to solve the issue. The Issue is, i have started the sendmail service on my RHEL 4 update 6 box, I am able to send the mail from my box to almost all of the Email Id's except few. Exampe, test mail. . Output is :the message is sent. now if I send the... (2 Replies)
Discussion started by: akhtar.bhat
2 Replies

6. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

7. Linux

uuencode not working

"uuencode" is not working for me kindly help me i am using Linux 2.4.9-e.72 enterprise #1 SMP Thanks, Anil (1 Reply)
Discussion started by: 150177
1 Replies

8. UNIX for Dummies Questions & Answers

Telnet is not working properly

telnet at my system is behaving stange. Some times I am able to telnet to other machines but sometimes it stop doing that. Then i have to reboot the machine and most of the time (not 100%) it works. SImilar is the case with SSH. Sometime it works , some time it don't. i am new to Unix and I do not... (1 Reply)
Discussion started by: deepak_pathania
1 Replies

9. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\> "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies

10. UNIX for Dummies Questions & Answers

Keyboard not working properly...

Hello Again, Those that have noticed my earlier posts will know that I have succesfully installed Solaris 8 onto my pc. I haven't been able to get x-server working (i think it doesn't like my video card) though I've been able to log into root (with a bit of help from unix forums :o ) and have... (2 Replies)
Discussion started by: timresh
2 Replies
Login or Register to Ask a Question