T.S. Ravi Shankar wrote:
> Hi,
> 
> At reaching a certain point in my perl program, I need to run a
> process ( say XYZ ) using SYSTEM command.  The result file that this
> process would produce will be result.<process_id>.  I will have to
> wait until this result file is produced & then proceed extracting
> certain things from this file.
> 
> I am implementing this as :
> 
> foreach $check  (@run)  {
> 
> $pid=fork;
> if($pid == 0) {
>   exec("XYZ  -a   $check");
> }else{
>   $pid1=wait;
> }
> 
> if ( -e "result.$pid1")  {

Seems like this should be "result.$pid", since $pid is the child process
number. $pid1 is the exit status from wait().

>   ##  perform operations on the file result.$pid1##
> }
> 
> system("rm  result.$pid1");

No need to use system() here; use unlink().

> 
> }
> 
> This seems to be performing inconsistently. I am  seeing this working
> properly sometimes & not working  properly sometimes.   This works on
> certain workstations & doesn't work on certain workstations.

-- 
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