[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] perl or system problem?



--- Terry <td3201@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@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