[EMAIL PROTECTED] wrote:
Perl'ers

I my code I wrote a routine that executes return code signals.  My point
being is if after any particular line of code make a call to check its
success or failure.
My question is if after any code system call or non system call failure
according to

$? == -1
? & 127                 or
$? >> 8

can I send an email with that return code in as the message and or subject?
I f so how and what would the code look like?

thank you,
derek


Please see lines 70-84 and 124

(See attached file: test.pl)


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams

I', not totaly sure about you if elsif elsif ...
waht about
if ( it breaks )
{
        $content ="more on $?";
        mailme($content,$?);
}
        
sub mailme
{
        my $stuff = "Command die with ",shift;
        my $content = "lots of text an stuff PLUS more on",shift;


        open(MAIL , "| /usr/sbin/sendmail -t") or die $!;
        my $msg = new MIME::Lite ;
        my $tomail="[EMAIL PROTECTED]" ;


        $msg = build MIME::Lite
                From    => 'your server' ,
                To      => $tomail ,
                Subject => "$stuff" ,
                Type    => 'TEXT',
                Data    => "$content";

        attach $msg
                Type     => "text" ,
                Path     => "/test.csv" ,
                Encoding => "base64",
                Filename => "$file.csv" ;

        $msg->print(\*MAIL) ;
        close(MAIL) ;
}


-------------the if it breaks part  ----------

my $status = $?;

my $error=$status & 0x00FF;
my $exam =$status & 0xFF00;

if ($error != 0)
{
        print "exit value $?\n";
        my $ex1 = ($exam & 127);
        print "show Signal $ex1 \n";
        my $ex2 = ($exam & 128);
        print "Coredump    $ex2 \n";
}

----------------------------------------------

with regards
MNibble

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to