954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How I can write shell script for Sending Email

I tried to Sends email but somehow email not getting out, please help me how I can write shell script in right manner. Thanks and regards

This is the one I tried my end.


Script:
#!/bin/sh
set wma = `grep -i "java" sampletest`
echo $wma
mail -v -s "ALERT" [email]tamilmercy@yahoo.com[/email] < alertfile


Result:
r.invoke.InvokeManager.process(InvokeManager.java:612) :i
[email]tamilmercy@yahoo.com[/email]... Connecting to [127.0.0.1] via relay...
[email]tamilmercy@yahoo.com[/email]... Deferred: Connection refused by [127.0.0.1]

tamilmercy
Newbie Poster
2 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

Hey There,

The last line of your script is actually okay. The error you're getting looks like it's coming from sendmail. Depending on what version you're running you may need to edit /etc/mail/sendmail.cf or /etc/mail/submit.cf and specify the IP of the host in DaemonPortOptions - It's either that or ClientPortOptions.

In any event, your script is okay. Looks like sendmail won't send mail no matter what you do right now.

If you invoke
/usr/lib/sendmail -v [email]tamilmercy@yahoo.com[/email]

and can post that output, I might be able to tell you what you need to do to make your mail work

Also - you can run
/usr/lib/sendmail -vb [email]tamilmercy@yahoo.com[/email]
if you want to get the verbose output but not actually send the mail.

Thanks :)

, Mike

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

Thanks for your kind reply. I like to write script as follow:

The script to be checked

- “error” message in current server log file
- If found error message than send alert email to system admin email address

I need to be checked on current date - file under log directory if anything “error” message appeared.

please help me out how I can write this type of script. Thanks

tamilmercy
Newbie Poster
2 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You