Monday 10 March 2014

python script with system command 1


NOTE: sudo apt-get install ipython [ To install ipython ]

#!/usr/bin/env python
# System Information Gethering Script
import subprocess

# Example:
# subprocess.call(["ls","-l","/tmp/"])
# Example: You can also use as following for the above command:
# subprocess.call("df -h", shell=True)

#Command 1
uname = "uname"
uname_arg = "-a"
print "Gethering system information with %s command:\n" %uname
subprocess.call([uname,uname_arg])

#Command 2
diskspace = "df"
diskspace_arg = "-h"
print "Gathering diskspace information %s command:\n" %diskspace
subprocess.call([diskspace,diskspace_arg])

No comments:

Post a Comment