system() forks a child to run the program via an exec and is supposed to wait for the child to finish. Assuming what you say is actually the problem (not the typo noted above):

I would suspect that the redirection to $temp$file is the problem with the system call returning while the shell is doing the write producing a race condition which perl is winning. Have you tried adding a say sleep 1; after the first system call to see if this fixes the problem?

To ensure that the first call has finished you could call it with backticks and capture the output. Then use perl to write $temp$file.

$data = `/3rdparty/perl/bin/sunos5/lwp-request -p http://proxy-syr.glo +bal.lmco.com $hostname$url -C $user:$password`; open F, ">$temp$file" or die "Can't write $temp$file, $1\n"; print F $data; close F; # you don't need the system call to do chmod as Perl has one chmod 777, $tempfile or die "Can't chmod $temp$file $!\n"; system("acroread -toPostScript $temp$file"); system("lp -d ep5_hpp01 $temp *.ps");

If none of that works you could resort to implementing the whole thing in pure Perl.

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Wait by tachyon
in thread system() not waiting by warwick

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.