Skip to content Skip to sidebar Skip to footer

Transparent Interaction With Console (sh,bash,cmd,powershell)

Please help me to write simple console application in python. It should redirect all input to system shell (bash or windows cmd or powershell) and give all their output to the scre

Solution 1:

I think you need

proc = subprocess.Popen(['bash'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

From the docs:

PIPE indicates that a new pipe to the child should be created. DEVNULL indicates that the special file os.devnull will be used. With the default settings of None, no redirection will occur; the child’s file handles will be inherited from the parent.

I don't think you want your bash to be connected to your parent process's stdin directly. That would explain wierdness.

Post a Comment for "Transparent Interaction With Console (sh,bash,cmd,powershell)"