LinuxQuestions.org
Review your favorite Linux distribution.
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 10-30-2009, 03:05 AM   #1
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Rep: Reputation: 30
output mail


I have a below script

for file in `ls -lt /tmp`
do
mail.pl myaddress@mydomain.com
done



it will send mail to me , can advise if I want the mail content is the output of the variable $file ,

I tried to modify it as below , but not work, can advise how to modify it ? thx



for file in `ls -lt /tmp`
do
mail.pl myaddress@mydomain.com < $file
done
 
Old 10-30-2009, 03:20 AM   #2
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Rep: Reputation: 51
What error its showing?
 
Old 10-30-2009, 04:03 AM   #3
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by your_shadow03 View Post
What error its showing?

it do not have error , but I can not receive the mail , if use << , the error is "line 7: syntax error: unexpected end of file"
 
Old 10-30-2009, 06:51 AM   #4
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Original Poster
Rep: Reputation: 30
what I would like to do is output the varible $file to the content of the mail , is it possible to do that ? thx
 
Old 10-30-2009, 10:40 AM   #5
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Original Poster
Rep: Reputation: 30
am I still not clearly state the requirement ?
 
Old 10-30-2009, 04:04 PM   #6
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
Impatient for an answer huh.

You script doesn't work because it doesn't make sense. < and << are for I/O redirection. You're not redirecting anything.


Code:
for file in $(ls -lt /tmp);do
echo $file | mail myaddress@mydomain.com
done
That will get you a bunch of emails each containing the name of one file that's in /tmp. If you want one email that contains the output of the ls command then you're really over complicating things as all you need is

Code:
ls -lt /tmp | mail myaddress@mydomain.com
 
  


Reply


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
cron e-mail output fyr3 Slackware 1 07-16-2007 03:51 PM
Sending output to mail account through cron. gian2oo1 Slackware 2 01-18-2005 01:54 PM
Returned mail: Can't create output: Operation not permitted turbo_acura Linux - General 0 10-19-2004 07:56 AM
standard output/system mail? gmon72 Linux - Newbie 2 10-13-2004 04:54 PM
standard output/system mail? gmon72 Linux - Newbie 1 10-13-2004 03:11 PM


All times are GMT -5. The time now is 08:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration