LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-22-2005, 06:56 AM   #1
humbletech99
Member
 
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
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Re:

Quote:
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
humbletech99
Member
 
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...
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:45 PM.

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