|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/22697/root/usr/lib64/python2.4/ |
Upload File : |
mò
‚=5Dc @ sF d Z d d d g Z d „ Z d „ Z d „ Z d „ Z d „ Z d S(
s- Execute shell commands via os.popen() and return status, output.
Interface summary:
import commands
outtext = commands.getoutput(cmd)
(exitstatus, outtext) = commands.getstatusoutput(cmd)
outtext = commands.getstatus(file) # returns output of "ls -ld file"
A trailing newline is removed from the output string.
Encapsulates the basic operation:
pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
text = pipe.read()
sts = pipe.close()
[Note: it would be nice to add functions to interpret the exit status.]
t getstatusoutputt getoutputt getstatusc C s t d t | ƒ ƒ S( s- Return output of "ls -ld <file>" in a string.s ls -ldN( R t mkargt file( R ( ( t /usr/lib64/python2.4/commands.pyR ! s c C s t | ƒ d S( s= Return output (stdout or stderr) of executing cmd in a shell.i N( R t cmd( R ( ( R R * s c C s{ d k } | i d | d d ƒ } | i ƒ } | i ƒ } | d j o
d } n | d d j o | d } n | | f S( s4 Return (status, output) of executing cmd in a shell.Ns { s ; } 2>&1t ri iÿÿÿÿs
( t ost popenR t pipet readt textt closet stst None( R R R
R R ( ( R R 2 s
c C s"