We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,731 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Issue with mail command mailing in script

Hi All

I have created a script which will email output if the file contains data, this works.
But when the file contains 0 data, it tries to email but hangs, when i hit ctrl D, it ask for Cc: address, i then cancel this then it emails me out.
Anyway i can get it to stop hanging and waiting for user intervention???

if [ $filesize -gt 0 ]
then
mailx -s "$subject $day" $destination < $filename
else
mailx -s "$subject2 $day" $destination
fi

2
Contributors
4
Replies
14 Hours
Discussion Span
5 Years Ago
Last Updated
5
Views
skelly16
Light Poster
34 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
echo "No Data" | mailx -s "$subject2 $day" $destination
masijade
Industrious Poster
Team Colleague
4,253 posts since Feb 2006
Reputation Points: 1,484
Solved Threads: 494
Skill Endorsements: 16

Hi

I tried that but it doesnt seem to work probably, as i had data in $filename, but it just ran echo "No Data" | mailx -s "$subject2 $day" $destination. For some reason it didnt pickup the data??


if [ $filesize -gt 0 ]
then
mailx -s "$subject $day" $destination < $filename
else
print "no date" | mailx -s "$subject2 $day" $destination
fi
+ [ 0 -gt 0 ]
+ print no date
+ mailx -s There are no Failed/Terminated jobs

skelly16
Light Poster
34 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Sorry it worked, being stupid i had the $filesize variable doing the work before the data came in.
Many thanks for your help masijade. :-)

skelly16
Light Poster
34 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Welcome

masijade
Industrious Poster
Team Colleague
4,253 posts since Feb 2006
Reputation Points: 1,484
Solved Threads: 494
Skill Endorsements: 16

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.5578 seconds using 2.64MB