Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Wait

by gbarr (Monk)
on Oct 03, 2001 at 01:32 UTC ( [id://116272]=note: print w/replies, xml ) Need Help??


in reply to system() not waiting

I see, at least in the first call, that you are passing a URL. Do any of the variables passed in contain & ?

system() with a single argument will call the shell which will interpret the & to mean background the process. If that happens system() will return straight away.

The solution is to use the multi-arg system(), but in the first instance you also want to redirect, so you may have to fork() and exec()

Something like

my $pid = fork(); if ($pid) { wait($pid); # Plus appropriate checking } elsif(defined($pid)) { open(STDOUT,">$temp$file") or die "Cannot open $temp$file: $!\n"; exec(qw("/3rdparty/perl/bin/sunos5/lwp-request -p http://proxy-syr +.global.lmco.com),"$hostname$url","-C","$user:$password"); die "Cannot exec: $!\n"; } else { die "Cannot fork: $!\n"; } system(qw(chmod 777),"$temp$file"); system(qw(acroread -toPostScript),"$temp$file"); system(qw(lp -d ep5_hpp01), $temp, glob("*.ps"));

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://116272]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found