Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I would like to have a perl script invoke a expect script and wait for compleation then a tcl script and wait for compleation. I have done this for perl scripts but I have had no luck with expect or tcl. The code I use for perl script is below.
my $pid = "$pid$_"; do{ $pid = spawn 'perl Start.pl' or die "spawn: $!"; print "************ PID NUMBER IS: $pid Starting\n"; my $num_proc = @pids; while ($num_proc) { for ( my $i=0; $i< @pids; $i++) { waitpid($pids[$i],0); print " PID $pids[$i] has exited \n"; $num_proc --; } } } until waitpid($pids,0);

Replies are listed 'Best First'.
Re: perl to invoke tcl and expect sripts
by ambrus (Abbot) on Jan 15, 2005 at 19:08 UTC

    I don't understand what these three loops are for. If all you want is spawning an external program and waiting for its completion, the simplest way is perlfunc:system.

Re: perl to invoke tcl and expect sripts
by Mr. Muskrat (Canon) on Jan 15, 2005 at 17:27 UTC

    "$pid = spawn 'perl Start.pl' or die "spawn: $!";"

    Do you mean fork or are you referring to the deprecated Win32 spawn function? It really does make a difference.