Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Child process opened using open function works fine but doesn't work with open2 function

by McA (Priest)
on Mar 28, 2013 at 08:30 UTC ( #1025894=note: print w/ replies, xml ) Need Help??


in reply to Child process opened using open function works fine but doesn't work with open2 function

Good morning,

IMHO the problem lies in the fact that the output of powershell can have more than one line. You simply don't know how much output (linewise) is produced by a command. So you don't know how much lines you have to read until you know you grabed the whole output ready to send the next command. This deadlock behaviour is mentioned by the docs of IPC::Open2.

So in your case (after a short look at the help screen of powershell) assuming that the startup of the powershell is more or less cheap I recommend to put the commands you want to be executed by powershell on the commandline of powershell or put it into a file to be read from the powershell and only connect STDOUT of the powershell with STDIN of your perl script to read the command's output.

McA


Comment on Re: Child process opened using open function works fine but doesn't work with open2 function
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-12-29 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls