Thanks, I had a look at fork() and system(). I think system() would
work better in my case.

Thanks!


-----Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED] 
Sent: 24 May 2005 02:34 PM
To: Tielman Koekemoer (TNE); Perl Beginners
Subject: RE: To Thread or not?

Tielman Koekemoer (TNE) wrote:
> Hi all,
> 
> I need to execute a shell command in a loop but the shell command 
> takes about 1 minute to complete. I want to execute the shell
command 
> but but then continue processing. Usually I would "background" the 
> process with & but this does not work as Perl waits for the process
to 
> exit before returning. Should I be using Thread to do this or is
there 
> another way?
> 
> I can write a shell script which then has the & included but that's 
> messy and I want to keep it clean.
> 
> E.g.
> 
> While (1) {
> 
> Some processing here..
> 
> ` execute some shell script/command here`; # takes about 60 seconds
to 
> complete
> 
> Would like to start processing as soon as the above command is 
> executed...
> 
> }

Use system("cmd &") instead of backticks and you can run the external
program in the background. Backticks imply that you want the output of
the external command, which would only be available by waiting for the
command to finish.

perldoc -q 'background'

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to