Possible duplicate:How can I write the output of stdout of a child process?
I run the cat program in bash from Python:
cat
import os os.system('cat foo.txt')
How to get shell command output back in a Python script, something like:
s = somefunction('cat foo.txt')
?
UPD : Here is the associated stream.
Use the subprocess module.
from subprocess import Popen, PIPE (stdout, stderr) = Popen(["cat","foo.txt"], stdout=PIPE).communicate() print stdout
Source: https://habr.com/ru/post/1286218/More articles:Problem adding checklist in Excel worksheet using VBA - listHow to connect a database in Silverlight applications - silverlightjavascript text compression / decompression - javascriptGet active tab in SWT TabFolder - javaError 3023 using Entity Framework - entity-frameworkStored procedure returning int - sqlHow to edit data in a nested Listview - c #SetWindowsHookEx - Dll Injection skips the first few calls - c ++Runtime.getRuntime (). Exec () hides console screen - javaWhy is the Java toString () loop infinitely linked to indirect loops? - javaAll Articles