Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
ikegami has advised the use of MIME::Lite but note that it is not a core part of Perl and would need to be loaded by your local friendly sysadm. (or your good self if you fill that role).

blazar has given a lot of good advice. I think it might be useful to expand on the use of system and how you would check that the command you ran succeeded or not. When you run a command it finishes with an exit status and, by convention, success is signified by an exit status of zero. When running from the shell in a terminal window of some sort you can check the exit status by examining a shell built-in variable, $? on Bourne and Korn shells (/bin/sh and /bin/ksh) or $status if using the C-shell (/bin/csh). You can do echo $SHELL to find out which you are using. Using the Korn shell you can see what happens when I do an ls on existent and non-existent files

$ touch goodfile $ ls goodfile goodfile $ echo $? 0 $ ls badfile badfile: No such file or directory $ echo $? 2 $

If I do the same thing using system in a Perl script (in this case actually typed in at the command line) I can still examine the exit status, this time using a Perl built-in variable also called $?. This time, however, there is more information available; see the system man page for the gory details but the bottom line is you have to shift $? right 8 bits to get the exit status. Like this

$ perl -le ' > @cmd = qw{ls goodfile}; > system @cmd; > exit unless $?; > print $?, q{ - }, $? >> 8;' goodfile $ perl -le ' > @cmd = qw{ls badfile}; > system @cmd; > exit unless $?; > print $?, q{ - }, $? >> 8;' badfile: No such file or directory 512 - 2 $

So, the point of the above is that it is good practice to check that your command actually ran rather than trusting to fate.

If you are wanting to capture the output of your bpdbjobs command in order to send it in an email you should be using backticks or qx{ ...}, ($output = `command`; or $output = qx{command};) instead of system. There are references on the system manual page to follow if that is what you want.

I hope you find this helpful.



Update: Corrected cut'n'paste error in the last paragraph.

In reply to Re: Okay I have cleaned it up a little bit by johngg
in thread Okay I have cleaned it up a little bit by Kevin_Raymer

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    LanX .oO( cemetery breweries ? )

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (10)
    As of 2017-12-15 11:15 GMT
    Find Nodes?
      Voting Booth?
      What programming language do you hate the most?

      Results (431 votes). Check out past polls.