Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I got this from one your Perl experts.
Please advise how I can get the print part to be an email message to my email????
#!/usr/local/bin/perl -w use strict; my @uptime = split //, `uptime`; print "Server rebooted in last 24 hours.\n" if ( $uptime[2] > 1 );

Replies are listed 'Best First'.
Re: Email printed message
by silent11 (Vicar) on Mar 08, 2002 at 21:15 UTC
    #!/usr/local/bin/perl -w use strict; my @uptime = split //, `uptime`; my ($to,$from,$subject) = ('mail@list.com','sys@admin.com','ALERT : re +boot'); if ($uptime[2] > 1 ){ open(MAIL, "|/usr/sbin/sendmail -t"); print <<MAIL; To: $to From: $from Subject: $subject Server rebooted in the last 24 hours. MAIL close(MAIL); }
    -Silent11
      Somehow it seems that it would make more sense if if ($uptime[2] > 1 ){ were if ($uptime[2] < 1 ){ instead.

      --t. alex

      "There was supposed to be an earth-shattering kaboom!" --Marvin the Martian

Re: Email printed message
by dws (Chancellor) on Mar 08, 2002 at 19:46 UTC
    Please advise how I can get the print part to be an email message to my email????

    Try searching on "email" or "mail". The details of sending email are doing to depend on your configuration. Fortunately, there are a multitude of examples on this site for sending email in various different ways.