pass
#!/usr/bin/env python import os,commands a = os.system(‘ls /mnt‘) print ‘a:‘,a print ‘------------------------------‘ (status, output) = commands.getstatusoutput(‘ls /mnt‘) print ‘status:‘,status, print ‘output:‘,output print ‘------------------------------‘ b = os.popen(‘ls /mnt‘) print b.read() # b 是一个 function
返回值:
[[email protected] test]# python cmd.py a.py logstash-patterns-core-master rhel.repo conf master rhel-server-6.5-x86_64-dvd.iso gems nginx-1.9.4 rsyslog.repo get_ip.py patterns test.py hgfs rhel tqt a: 0 ------------------------------ status: 0 output: a.py conf gems get_ip.py hgfs logstash-patterns-core-master master nginx-1.9.4 patterns rhel rhel.repo rhel-server-6.5-x86_64-dvd.iso rsyslog.repo test.py tqt ------------------------------ a.py conf gems get_ip.py hgfs logstash-patterns-core-master master nginx-1.9.4 patterns rhel rhel.repo rhel-server-6.5-x86_64-dvd.iso rsyslog.repo test.py tqt
时间: 2024-10-08 09:26:27