amitrev has asked for the wisdom of the Perl Monks concerning the following question:
sub returnVersion() { my $cmdToExecute = "dds_cmd -Version "; my $versionNum; my $PH; if (!open($PH, "$cmdToExecute 2>&1 |")) { print STDERR "Failed to execute command:($cmdToExecute)--$!\n"; exit 1; } while (my $line = <$PH>) { if (index($line, "Command Execution ") != -1){ $line =~ s/^.+version\s|\.0.$//g; $versionNum = $line; } } close($PH); return $versionNum; }
So the execution hangs on line "while (my $line = <$PH>) {".
If I execute the "cmdToExecute" manually on cmd works fine-returning 3 lines of text as expected. If I separate this code in separate .pl file and execute it also works fine-and the command returns 3 lines of text.
I don't know why is this happening and why it wont work in my code.And the strange is that this problem appears only on win2003. On every other platform works fine
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Execution of external command hangs
by Old_Gray_Bear (Bishop) on Aug 29, 2013 at 23:31 UTC | |
by amitrev (Initiate) on Aug 30, 2013 at 13:43 UTC | |
|
Re: Execution of external command hangs
by BrowserUk (Patriarch) on Aug 29, 2013 at 23:26 UTC |