Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-22-2005, 06:56 AM   #1
Registered: Jun 2005
Posts: 374

Rep: Reputation: 30
Writing shell script with mail < logfile

I've writen a shell script with the command line mail program to tell me what's going on but I can't seem to get the logfile to dump into the body of the email.

I was doing it and now it won't do it any more, the logfile just becomes the generic "attachment" which is not the desired effects, especially because of the incompatibility of unix/windows ascii newlines.

The command is

mail myemailaddress -s "Subjectline" < var/log/logfile

I thought it might have to do with the length, but I was sending longer logs in the body before.

Any ideas on piping the logfile into the actual body of the mail instead?
Old 11-22-2005, 07:06 AM   #2
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57

Originally posted by humbletech99

mail myemailaddress -s "Subjectline" < var/log/logfile
I don't understand "the logfile just becomes the generic attachment"

Independently of that , mail needs the email adress at the last argument :

mail -s "subject" mymailaddress < /var/log/logfile

Should send you a mail with in the body the content of /var/log/logfile

You can also play with mutt if you want to create an attachment.
Old 11-22-2005, 08:20 AM   #3
Registered: Jun 2005
Posts: 374

Original Poster
Rep: Reputation: 30
I mean it becomes an attachment without a name, with standard unix ascii so it's inconvienient in M$ desktops

it's ok, I've come up with a solution, stripping out returns before piping to mail sorted it and nows dumps it into the body of the message.

Also, you can put the -s "Subject" and user the other way round...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell scripting: Print output to logfile, error to logfile & screen stefanlasiewski Programming 18 05-22-2008 12:47 PM
[SOLVED] Writing a shell script mattz40 Debian 5 04-13-2005 06:56 PM
writing a shell script tchoua Linux - General 8 02-24-2005 06:18 PM
shell script writing ust Linux - General 6 01-24-2005 01:06 PM
Need Help in Writing a Shell Script. KptnKrill Linux - General 2 05-19-2003 05:44 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration