>>> import os >>> prc = os.popen('ls -al') >>> argout = prc.read() >>> prc.close() >>> print( argout) total 40 drwxr-xr-x 2 kracht users 20480 Dec 9 14:22 . drwxr-xr-x 96 kracht hasylab 12288 Dec 9 11:36 .. -rwxr-xr-x 1 kracht hasylab 194 Aug 1 14:06 Clean.pl -rwxr-xr-x 1 kracht hasylab 450 Dec 9 14:16 t1.py
Notice that, if a call to a sub-shell has to be protected by a time-out, it has to be done this way 15.6.5.