ikkeniet has asked for the wisdom of the Perl Monks concerning the following question:
use Win32::Job; my $timeout = 30; # sec my $retry = 3; # times my $exe = "dir"; my $ok = 0; my $pid = undef; my $job = undef; # Try to execute command up to $retry times while ((! $ok) && ($retry > 0)) { # Create job $job = Win32::Job->new; # Create a new process and associate with the job $pid = $job->spawn("cmd", q{cmd /C $exe}, ); print "PID:$pid\n"; print "SYS:$^E\n"; # Run the job and kill it if more than $timeout sec $ok = $job->run($timeout); $retry = $retry - 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use variable in Win32::Job to execute command line
by chrestomanci (Priest) on Dec 07, 2010 at 22:11 UTC | |
|
Re: Use variable in Win32::Job to execute command line
by ikkeniet (Acolyte) on Dec 08, 2010 at 13:32 UTC |