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
Post a Comment