On my system, scp return an error code on error. ("DIAGNOSTICS: scp exits with 0 on success or >0 if an error occurred.") system returns and sets $? to a value that contains the exit code of the process it launched.

my $filetoget = "$f.\@FILEDOMAIN$i.$year-$mon-$mday"; my @cmd = ( '/usr/bin/scp', "$a:$LOGFILEDIR/$filetoget", "$filetoget.$a", ); my $rv = system(@cmd); if ($rv == -1) { print("Unable to execute scp: $!\n"); } elsif ($rv & 127) { printf("scp died with signal %d\n", ($rv & 127)); } elseif {$rv >> 8) { printf("scp exited with error %d\n", ($rv >> 8)); } else { print("scp was successful\n"); }

As for the email part, MIME::Lite should do the trick.

Update: Oops, was missing scp's 2nd arg.


In reply to Re: help with scp error codes by ikegami
in thread help with scp error codes by wskibum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.