i am new learner from shell scripting.. any one help me.

hi every body, i am ramesh.

i want write about this shell program (" i have 94 server's like aix, solaris, linux, hp-ux, and sco unix-") how to get mail's from these server's?

(i have personal linux system)- i want to run this program in my personal linux system continuously.

i want to write the program for got mail's, when in the 94 server's any one server is goe's down. at that time i want to got mail from that server information details.

any one help me............
i am waiting for ur reply..........................

---------- Post updated at 04:39 PM ---------- Previous update was at 12:28 PM ----------

help me anyone.....

You have to consider for what reason a server goes down. If it has a serious problem, it will most probably not be able to send you an email in time. This would be very unreliable.

Maybe think about like a ping/nmap probing script, that runs on your Linux box scanning the remote hosts in some interval.
There is other versions of ping out there, that can already work on a whole input list/file of hostnames instead of running in a while loop every host against a ping.

1 Like

zaxxon:

i want shell program for send mail.." my pc to my friend yahoo mail"

u know the this program?

Usually it's just mail which can be a link on some more capable mailer like mutt, mailx and so on.

echo "here comes my text blablabla..."| mail -s "Some Subject" myfriend@somedom.com

Don't forget to use the search function of the forum :slight_smile:

Well there my friend, you could use a very simple perl script to preform the mail functions.

First, you could have to ping/nmap script write to a log file or an array/hash.

Or even call it in a function.

#!/usr/bin/perl

... ping/nmap script here ...

sendMail(@nnamp_output);

sub sendMail {
open (OUT,"|/usr/sbin/sendmail -t");
print(OUT "From: i.am.leet\@space.mars\n"); ## don't forget to escape the @
print(OUT "Date: |/usr/bin/date\n");
print(OUT "To: i.am.leet\@space.mars\n");
print(OUT "Subject: Errors\n");
print(OUT "\n");
print(OUT "\n");
foreach ($_)
{
print(OUT "$_");
}
print(OUT "\n");
close(OUT);

}
exit 0;

Prior to this, you have to have a mail server eligible to accept and send this request. I run an OpenRelay here for the internals.

Hope this helps!

1 Like