My first question is why you want to background this process when the first thing you are doing is checking for the existance of the output file. It is concievable that your process execution will not happen in time before Perl does its test for the file.

My next observation is that the reason your "ps" is failing is system thinks you are passing the ">", "test1.out" and "&" as arguments to "ps;" versus redirecting the output of "ps" to "test1.out".

is probably more in line with what you have in mind or if you are really intent on backgrounding the "ps" command.

Yet another way instead of using system would be as follows:

This way you background the process and wait for it before you do your test for file creation. YMMV based on how waitpid is implemented on your local system.

There are lots of other ways of doing this, but this is my (current) favorite.

References:


Peter @ Berghold . Net

Sieze the cow! Bite the day!

Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.

Brewer of Belgian style Ales


In reply to Re: Trying to understand the System function by blue_cowdawg
in thread Trying to understand the System function by mifflin

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.