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

I’ve perl script calling ‘X.pl’.
How can I running that script from ‘Y.pl’ by using ‘open’ command and while command and add more manipulation on it like timer and etc.
Somthing like the following example:
my $buildCMD = "$sshCMD \"perl $VM_HOME/X.pl " . "-u $ST_USER " . "-p $ST_PASSWORD " . "-v $ST_VIEW " . "-l $ST_LABEL\""; print "-I- $buildCMD"; open (CMD, "$buildCMD | ") or die "\n-E- system '$buildCMD' failed: ($ +?) ($!)"; while (<CMD>) { print "$_\n"; sleep 1; $counter++; if ($counter < 18) { print "\n-E- TimeOut.\n"; exit 1; } }
Because when I opened Perl command using 'open' command the script start to run and I can add more manipulation on it like timer and etc.
Please advice

Replies are listed 'Best First'.
Re: Running perl script with open command
by almut (Canon) on Apr 20, 2009 at 13:05 UTC

    You forgot to mention what your problem is :)

    Essentially, what you've attempted should work, presuming you fill in appropriate values for the variables you haven't defined here...

    What looks a bit weird, though, is this piece

    $counter++; if ($counter < 18) { print "\n-E- TimeOut.\n"; exit 1; }

    Depending on what value $counter starts with, it will either exit immediately (after the first line having been read), or never. I.e. in case $counter starts with 18 or greater, incrementing it further will not make the condition $counter < 18 ever become true...