capture 'system' output 
Author Message
 capture 'system' output

Using SunOS 4.1.
How does one code the eqivalent of this perl statement in python?


Perhaps part of the solution is NOT to use:

        posix.system("ph any name")

Ray Price
Office of the Registrar
Univ of CA, Irvine
(714)856-7428



Mon, 14 Apr 1997 23:54:52 GMT  
 capture 'system' output

Quote:
> How does one code the eqivalent of this perl statement in python?



If I understand well that this stores the output from the shell
command "ph any name" in a variable named retval, the solution is

        retval = os.popen("ph any name", 'r').read()

Or if you wanted an array of lines, use readlines() instead of read().
python does not strip the final newline in either case.


<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>



Tue, 15 Apr 1997 08:21:10 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SUMMARY (followup): capturing output from exec'd command

2. SUMMARY: capturing output from exec'd command

3. Capturing output from exec'ed command

4. Capturing System Command Output (was: SH Backquote)

5. Capturing System Command Output (was: SH Backquote)

6. Capturing System Command Output

7. Capturing output from Kernel#system

8. capturing output of os.system() into a list?

9. capturing a call system() output into a variable

10. capturing output from os.system() in Windows?

11. 'split' creates extra output

12. Outputting 'Raw' printer data

 

 
Powered by phpBB® Forum Software