How to attach a file & send mail thru script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to attach a file & send mail thru script
# 1  
Old 10-10-2006
How to attach a file & send mail thru script

In shell script how can I attach a file and send a mail.

suppose if I written like the following way

usr/bin/mail 'subject" "mail_id" < file.

a mail goes to the mail-id with the content of file.But I want the file to be atttached to the mail.How can I get it.is there any way for this.

Thanks
Kanth
# 2  
Old 10-10-2006
i think this will work.

usr/bin/ file1.txt | mailx "subject" "mail_id"

Regards,
Swapneel
# 3  
Old 10-10-2006
Read the FAQ
# 4  
Old 10-11-2006
Quote:
Originally Posted by d_swapneel14
i think this will work.

usr/bin/ file1.txt | mailx "subject" "mail_id"

Regards,
Swapneel
it is not working.I am using sun solaris.
# 5  
Old 10-11-2006
Quote:
Originally Posted by Mar1006
it is not working.I am using sun solaris.
it does not work, so give the error messages you encountered.
Also, did you even try to see what usr/bin/ is on the shell command line??
the actual command might be
/usr/bin/cat file.txt | mailx .........or something similar..
# 6  
Old 10-11-2006
MySQL

Quote:
Originally Posted by ghostdog74
it does not work, so give the error messages you encountered.
Also, did you even try to see what usr/bin/ is on the shell command line??
the actual command might be
/usr/bin/cat file.txt | mailx .........or something similar..

When I use the following command at command prompt it is working.

uuencode filename filename | mail "mail_id".

but when I use in the script it is not working and giving the error

SP2-0734: unknown command beginning "/usr/bin/u..." - rest of line ignored.

before this i open sql connection.I have to close this conncetion before using this command.i will check it.

again problem.
when i use
uuencode "filename" | mailx -s "subject" "mail_id".
it is showing subject but it is not attaching the file to the mail

when i use
uuencode "filename" | mail -s "subject" "mail_id".
it is attaching file but subject is not showing in mail.b'se sun solaris 5.9 does not allow mail command to show subject.

how to do it.

Last edited by Mar1006; 10-11-2006 at 06:47 AM..
# 7  
Old 10-11-2006
This topic has been discussed many times, a quick search through this forum can help you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to attach latest files of directories in a mail.

Hello Folks, I am looking for the script which will go to directory and check for the latest 5 files and send a mail to attaches these files to user. Kindly guide. Regards (7 Replies)
Discussion started by: sadique.manzar
7 Replies

2. Shell Programming and Scripting

Need Script to ZIP/SAVE & then DELETE Log file & send a mail conformation for any error

ENVIROMENT Linux: RHEL 6.4 Log Path: /usr/iplanet/servers/https-company/logs Log Format: user.log.03-15-2015 I have log4j log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I need a script that will run daily that... (1 Reply)
Discussion started by: admin_job_admin
1 Replies

3. Shell Programming and Scripting

UNIX - how to send attach excel in mail

Hi Experts, i need your help here :confused: Need to send a report thru mail using unix shell script(AIX). can you help me to do this? . i tried "uuencode" with CSV format, but while reading report all values are in single column. i need each column values in separate cell. Thanks in... (9 Replies)
Discussion started by: newbieabc
9 Replies

4. Shell Programming and Scripting

How to attach multiple file to send mail command

Hi, i want color effect on mail as well as multiple attachment.I have code but this code is used for single attachment. I am unable to attach more than one file.:wall: I want to send two attachments -ahmed.csv and ahmed1.csv . Sample content: <html> <body> <b> Hi...</b> </body> </html> ... (1 Reply)
Discussion started by: AhmedLakadkutta
1 Replies

5. Shell Programming and Scripting

Script to attach file to mail

Hello, I have a .dat file containing one line. I need a script to read that line and make it part of the body and send a mail... Let's say the line is $line. I need the script to send a mail with the body "The last disposal feed is $line". Thanks (4 Replies)
Discussion started by: sfetea
4 Replies

6. Shell Programming and Scripting

How to attach a file in Linux mail command

How to attach a file in Linux mail command Hi Guys, Is there any way to attach a file in Linux mail command without using "uuencode"? i.e. Code: file=/a/b/c/d/file.txtmail -s "Giga aks" abc@123.com <<HDoc`uuencode $file $file 2>/dev/null`HDoc Here, I don;t want to use 'uuencode'... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

7. UNIX for Advanced & Expert Users

Script which can send file to diffrent mail ids.

Hi i am looking for the script which can send file to different mailids, please halp me out. Thanks in advance. (3 Replies)
Discussion started by: vpandey
3 Replies

8. Shell Programming and Scripting

script to find a file and send a mail

I need a shell script which checks for a file in a particuler folder and should send me a mail if the file of that name is present. Please help me on this.I am new to shell scripting. (6 Replies)
Discussion started by: jayaramanit
6 Replies

9. Shell Programming and Scripting

Need to attach a txt file while sending mail

Hi, I need to attach a txt file while sending mail thru Unix. Please help me out in this.. -Charan. (9 Replies)
Discussion started by: charan81
9 Replies

10. UNIX for Dummies Questions & Answers

How to attach a file in mail?

Hi, I want to know how to send a mail in unix using mailx or mail or sendmail to send a mail with a file attached. I have read the answers from the other threads but I still don't understand. I want to do it in the command line as well as in script. Can anyone help? DO I need to use... (1 Reply)
Discussion started by: firebirdonfire
1 Replies
Login or Register to Ask a Question