#!/bin/sh
## Save STDERR; Redirect to /dev/null while we search for a version of Perl with Net::SMTP;
exec 3>&2 2>/dev/null
test -z "$perl" && test -x /usr/local/perl5.8.5/bin/perl && perl=/usr/local/perl5.8.5/bin/perl
test -z "$perl" && test -x /usr/local/perl5.6.1/bin/perl && perl=/usr/local/perl5.6.1/bin/perl
test -z "$perl" && test -x /usr/local/bin/perl && perl=/usr/local/bin/perl
test -z "$perl" && test -x /usr/bin/perl && perl=/usr/bin/perl
test -z "$perl" && test -x /usr/cisco/bin/perl && perl=/usr/cisco/bin/perl
test -z "$perl" && test -x /usr/local/bin/perl5.6 && perl=/usr/local/bin/perl5.6
export perl
## Restore STDERR from fd 3 and close fd 3.
exec 2>&3 3>&-
## Start the selected version of perl; "-x" says to ignore everything up to #!perl.
exec $perl -x $0 $*
#!perl
$ENV{PATH} = "/usr/sbin:/usr/bin:/usr/lib:/bin";
chomp($thisHost = qx{uname -n});
chomp($os = qx{uname -s});
chomp($release = qx{uname -r});
$interval = 120; # Interval, in seconds.
if ($os eq "Linux") { ...
This is where I post snippets of information about Information Technology. It is mostly for my own reference but I hope that others will find it useful and comments are welcome.
Monday, February 14, 2011
Interesting way to start Perl
Subscribe to:
Post Comments (Atom)
You don't need to run external program to get OS name, use $^O variable.
ReplyDeleteNet::SMTP is included into perl 5.8, so you can just use any 5.8.x version.