attaching file in mail command from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting attaching file in mail command from shell script
# 1  
Old 12-11-2009
attaching file in mail command from shell script

Hi all,

Currently in shell script i am using the following command to send mail
Code:
echo "Certain assets are not loaded properly. PFA the result of the DataLoad" | mail -s "Weekly DataLoad - Failure Notification !!" $MAILINGLIST

I need to attach a file along with that. How should i handle this in my mail command.

Thanks in advance.


Thanks,
Ananthi.U

Last edited by zaxxon; 12-11-2009 at 03:55 AM.. Reason: use code tags please
# 2  
Old 12-11-2009
Search the forum for uuencode please. There should be plenty of examples.
# 3  
Old 12-11-2009
I tried using the following command

Code:
uuencode $outputFile | echo "Test mail" | mail -s "Mail notification" $MAILINGLIST

But i m getting only the mail but not the attached file.

Also that script is not stopping. It is running with out end.

suggest some solutions

Last edited by zaxxon; 12-11-2009 at 07:32 AM.. Reason: code tags please
# 4  
Old 12-11-2009
try;

Code:
uuencode $outputFile $outputFile | mailx -m -s "Mail notification" "$MAILINGLIST"

# 5  
Old 12-11-2009
As said, there are many post you can find using the search function of the forum. It should have brought something like:

Code:
(echo "this is the mail body"; uuencode myfile myfile)| mail -s "subject in here" jupp@bla.com

# 6  
Old 12-11-2009
i tried with mailx. But i got mailx not found.

so tried the following command

uuencode $outputFile $outputFile | mail -s "Mail notification" "$MAILINGLIST"

mail came with attachments.

The issue i am facing is if my $outputFile = /opt/shared/result.txt, the file name in the attachment is named as optsharedresult.txt. Is there any option to configure the file name?

Also for bringing in the mail content i tried with the following code:

uuencode $outputFile $outputFile | echo "Certain assets are not loaded properly. PFA" | mail -s "Mail notification" "$MAILINGLIST"

but with this attachment mail body is coming but my attachment is not coming.

Please clarify.
# 7  
Old 12-11-2009
uuencode $outputFile $outputFile

the second argument is the destination filename itself.
you can change it to anything.

uuencode $outputFile my_new_file

answer to your second issue has been already answered by zaxxon.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to monitor new file in a directory and mail the file content

Hi I am looking for a help in designing a bash script on linux which can do below:- 1) Look in a specific directory for any new files 2) Mail the content of the new file Appreciate any help Regards Neha (5 Replies)
Discussion started by: neha0785
5 Replies

2. Shell Programming and Scripting

How to call mail id from different file in shell script?

Hi Team, Please can anyone tell me how to call mail ids from different file in shell script. For Example: ========= export MAILX=/bin/mailx export MAIL_DBA=xxx@gmail.com,yyy@gmail.com,zzz@gmail.com sendalertmess() { MESSAGE="ALARM" echo $MESSAGE | MAILX -s "uname -n :Oracle error"... (3 Replies)
Discussion started by: indira_s
3 Replies

3. Shell Programming and Scripting

Mail not attaching the attachment when schedule in crontab

Hi , Iam want to send the mail with attachment , iam using below in my script uuencode /path/pathname/filename filename.csv | mailx -s "subject of mail" vinoth@xxx.com when i trigger the script manually from command prompt i can get with the attachment but when i schedule it in crontab... (4 Replies)
Discussion started by: vinothsekark
4 Replies

4. Shell Programming and Scripting

Shell script for creating log file and sending mail?

Hi , I am trying to create shell script which will help me to compare file name in two folder. There is a multiple file store in 2 folder.I want to compare that with the name. If all the file are same then send a mail that "all date is same" if not then create one log file which contain... (4 Replies)
Discussion started by: san_dy123
4 Replies

5. Shell Programming and Scripting

Problem in attaching CVS file to the mail

i wrote this code(( cat $REPORT_EMAIL;uuencode <$OUTFILE $OUTFILE ) | mailx -s "Auto Policy Attach Report Before batch job " $SUPPORT_EMAIL_GRP) in my shell script to attach afile but in the mail i donot get a attachment contais of the mail is Auto Policy Attach Report Before batch job... (0 Replies)
Discussion started by: alokjyotibal
0 Replies

6. Shell Programming and Scripting

attaching the file to mail

Hi, In my script, i am using tar to combine 2 files, so that i can attach it to the mail. everything is working fine and sending the mail successfully. But, when i save the file to desktop and unzip it. a series of directories are there and finally those tar files are there. i am using tar -cf... (1 Reply)
Discussion started by: javeed7
1 Replies

7. Shell Programming and Scripting

Attaching file and sending text in body using sendmail command!!

Hello, I need to send with text in the body and 2 files as attachments using sendmail command. i can send only one at a time either attachment or text in body of email. Can any one please help me how to get that? I will be great for any help. Thanks, Sparan (1 Reply)
Discussion started by: sparan_peddu
1 Replies

8. HP-UX

Attaching files in Mail with HP Unix

I am trying to attach a .xls file using uuencode in HP Unix uuencode res1.xls res1.xls | mailx abc@xyz.com But in the receiving end, I couldn't see the attachement, instead of it some encoded text is there in the body of mail Can anybody suggest how to attach the files in HP Unix. I don't... (12 Replies)
Discussion started by: unipepper
12 Replies

9. Shell Programming and Scripting

How to use mail,mailx command in Shell Script ?

Hi.. How can i use mailx,mail command in Shell Script. Suppose i gave a condition that x value is above 25 send a mail alert to abc@rediffmail.com. How can i do this? Regards Sollin (16 Replies)
Discussion started by: sollin
16 Replies

10. Shell Programming and Scripting

Mail command in a shell script

i wanted to write a shell script that can automatically read unread mails and copy each one into a different file. I was trying to use the MAIL command to do it, but this command requires user input inbetween, I was wondering how that could be achieved in a shell script. Can sumone please suggest... (0 Replies)
Discussion started by: garric
0 Replies
Login or Register to Ask a Question