subprocess - How do I spawn a shell sub-command, with its stdout bound to the parent's stdout in python -


I want a Python program to underlay Shell sub-command, as well as be written to the stdout of the shell stdout Python's parents have been

Python scripts will be run as CGI so Shell output should be sent back to the browser.

As is said (emphasis my)

stdin, stdout And specify the stderr execute program handles standard standard standard output and standard error file, respectively valid values ​​are PIPE, an existing file descriptor (a positive integer), an existing file object, and none. Pipe indicates that a new pipe should be made for the child. With no default settings, no redirection will occur; The child's file will be inherited from the handle, parental. Additionally, stderr can be STDOUT, which indicates that the stderr data from the hair process as stdout should be captured in the same file handle. /P>

Therefore, it should be as easy as

  subprocess.call (["your_shell_command", / * command line argument, if any / code> < Subprocess.col (["MKDIR", "Nieder"]) subprocrio ("your_shell_script"); / pre> 

example

  subproc.close (["ls", "-l"]) .sh ")    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -