Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by McA (Deacon)
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 scrutinizing the Monastery: (6)
As of 2014-07-29 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls