LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-14-2007, 02:42 AM   #1
Patrick Chuang
LQ Newbie
 
Registered: May 2006
Posts: 1

Rep: Reputation: 0
Using awk together with linux mail commands


Hi Everyone

I am a newbie at Linux. Appreciate if anyone of you guys can help me out..

I am trying to send out the daily log files generated from our application. Currently there is a file - "log_req" containing all the files that need to be sent daily. As a test, the log_req file contains 2 file names. I need to know whether we can use a combination of awk and mail commands to send based on redirection.

The command I am trying to figure out is this:-

awk 'BEGIN{while (getline line_data < "log_req") "mail patrick.chuang@abc.com" < line_data}'

I do not encounter any syntax errors but somehow I dont receive any email. I tested with the print command and the information from the log_req files are retrieved.

awk 'BEGIN{while (getline line_data < "log_req") print}'


What i want to achieve would be to send all the files in the log_req file to the receipient.

Grateful if you can advice.

Thanks
Patrick..
 
Old 03-15-2007, 02:49 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
You could get "nail" (which is almost a dropin replacement of /bin/mail) and use it's -a option to attach the necessary files.

Something like this may help too:
Code:
oldIFS=$IFS;
IFS="\n"; #makes it ignore spaces and tabs in filenames
for file in `cat log_req`; do
   mail patrick.chuang@abc.com < $file;
done;
IFS=$oldIFS; #restore original value
Have you tried sending mail to the same address from the command line (just run "mail patrick.chuang@abc.com", type in the message and Ctrl-D to end it). If that doesn't work either, then the problem is with your e-mail setup (ie sendmail config) rather than with your commands.
 
  


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
Script help for awk and timing commands jakev383 Linux - General 2 12-18-2006 07:35 PM
e-mail commands paul_mat Linux - Networking 3 04-24-2006 03:55 AM
No mail in Solaris Cron commands markraem Solaris / OpenSolaris 1 01-05-2004 03:11 PM
How do I zip and attach the output data of a grep | awk | mail shell script? 360 Programming 1 05-08-2002 08:26 AM
How do I enter a subject when awk | data to mail 360 Programming 3 05-06-2002 08:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:33 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