[root@bogon IP]# vim bash4.py
!/usr/bin/env python
import commands
commands = commands.getoutput("date")
print commands
测试:
[root@bogon IP]# python bash4.py
Mon Jan 11 09:24:56 PST 2016
[root@bogon IP]# vim bash4.py
import commands
commands = commands.getoutput("date")
print commands
测试:
[root@bogon IP]# python bash4.py
Mon Jan 11 09:24:56 PST 2016