[Omaha.pm] perl or system problem?

Hugh Jarce hjarce2001 at yahoo.com
Thu Oct 21 18:39:54 CDT 2004


--- Terry <td3201 at gmail.com> wrote:
> Hello,
> 
> I have a hunch this is something to do with my environment .....
> 
> I am running this program out of cron:
> 
> #!/usr/local/bin/perl
> 
> use Mail::Sendmail;
> 
> $hostname = `hostname`;
> $message = `pprosvc -n -l`;
> unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , 'plasmtp';
> %mail = ( To      => 'jo at hotmail.com',
>         From    => "admin\@$hostname",
>         Subject => 'available packages',
>         Message => "$message"
> );
> sendmail(%mail) or die $Mail::Sendmail::error;

Let perl tell you what's wrong. For example:

    $message = `pprosvc -n -l`;
    my $rc = $? >> 8;
    warn "command failed (rc=$rc): $!\n" if $rc != 0;

Or more elaborately (taken from: perldoc -f system):

    if ($? == -1) {
	print "failed to execute: $!\n";
    } elsif ($? & 127) {
	printf "child died with signal %d, %s coredump\n",
	    ($? & 127),  ($? & 128) ? 'with' : 'without';
    } else {
	printf "child exited with value %d\n", $? >> 8;
    }  

Hugh



		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


More information about the Omaha-pm mailing list