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" tamilmercy@yahoo.com < alertfile


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

Recommended Answers

All 2 Replies

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 tamilmercy@yahoo.com

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 tamilmercy@yahoo.com
if you want to get the verbose output but not actually send the mail.

Thanks :)

, Mike

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 -<serverYYMMDD.log> file under log directory if anything “error” message appeared.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.