hi.. how to attach a tar file using shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting hi.. how to attach a tar file using shell script
# 1  
Old 10-16-2007
hi.. how to attach a tar file using shell script


How to attach a tar file using shell script or the command liine..

I following command just send the mail to the person with .txt file as body, I want to send it as attachment.

/usr/sbin/sendmail -f "user1@daemon.com" user2@daemon.com <hi.txt

The contents of the hi.txt will be sent as the body of the message..

Please help..... Thanks in advance..

# 2  
Old 10-17-2007
There is no simple oneliner for doing this. The classic UNIX way would be to uuencode the tarball and embed it as part of your message. There are however a number of ways of building a message with an attachment.

The following should work if your version of uuencode supports the -m option (but I have no tested it!)

(cat hi.txt ; uuencode -m file.tar tarball) | sendmail -f "user1@daemon.com"

Here are a couple of pointers:

Mailing Attachments from UNIX
Sending email with a text message and an attachment from standard UNIX.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to make Shell script of using tar command?

Hi Guys, I have to make shell script means tar all files from path /home/admin and move to path /dis/wis/ Please help me. (5 Replies)
Discussion started by: aaditya321
5 Replies

2. Shell Programming and Scripting

I need to attach a file in Linux SHELL Scripting

Hi Geeks, I'm trying to write a script to display the errors in a HTML table format and also it should attach the file and it should display the table in the body of the email. Well i wrote the script successfully and i have got the result, but either table is displaying in the email but not... (2 Replies)
Discussion started by: naren nandale
2 Replies

3. UNIX for Dummies Questions & Answers

Executing a tar command with the --exclude option in a Debian shell script.

Hi All, I am trying to execute the following tar command with two --exclude options to suppress extract of the two directories specified. Do I need to single quote the directory paths ?? Many thanks for your help. The relevant code excerpt from the script is: cd /var/www/${SITE} ... (7 Replies)
Discussion started by: daveu7
7 Replies

4. Shell Programming and Scripting

Loading a tar file into the shell script

Hi All, I am trying to write a shell script in which the contents of a small tar file is loaded into a variable and the same variable contents is moved into another file and finally untaring of the newly created file is done. The Shell Script is as follows: #----Start Of The... (11 Replies)
Discussion started by: wini008
11 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

Attach a binary file to email in a script

Hi, I am trying to get an email sent out by the unix ( aix ) system that has a .gz file attached to it. I can get the attachment, but it's not working when being looked at from outlook. I think there is a problem because of the way I am doing it, and the fact that it's binary. I am trying to... (15 Replies)
Discussion started by: fwellers
15 Replies

7. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

8. Shell Programming and Scripting

shell script to selectively tar directory based on date

hye everybody :) , i'm new to the scripting world.. hope you guys can help me out with this one.. i'm trying to identify any directory under /tmp/saya that is created more than one day from the current date.. e.g, today is March 14, so any directory that has time stamp March 13 backwards, i... (2 Replies)
Discussion started by: fara_aris
2 Replies

9. Shell Programming and Scripting

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. ... (9 Replies)
Discussion started by: Mar1006
9 Replies

10. Shell Programming and Scripting

Using tar inside a shell script

Hi, I am using tar cvf inside a shell script to archive files. Is there an option to surpress any prompts which come up if the desired archive name already exists ? Thanks in Advance. Kas. (2 Replies)
Discussion started by: kas7225
2 Replies
Login or Register to Ask a Question