Example 1: Wrap the ls command in python #! /Usr/bin/env python # python wapper for the ls commandimport subprocesssubprocess. call (["ls", "-l"]) in Linux, run this command [root @ pydb python] # python ls. pytotal 8-rwxrwxrwx 1 root 415 Mar 18. py-rw-r -- 1 root 103 May 4 ls. under py, expand [root @ pydb python] # python ls. py #! /Usr/bin/env python # python wapper for the ls commandimport subprocesssubprocess. call (["cat", "/python/ls. in Linux. A very good example. Remember: The following example prints the system information and disk information: copy the Code #! /Usr/bin/env python # A System Information Gathering Scriptimport subprocess # command 1 uname = "uname" uname_arg = "-a" print "Gathering system information with % s command: \ n "% unamesubprocess. call ([uname, uname_arg]) # command 2 diskspace = "df" diskspace_arg = "-h" print "Gathering diskspace information % s command: \ n" % diskspacesubprocess. call ([diskspace, diskspace_arg]) Copy code. below is the printed data copy code that I run locally [root @ pydb python] # python info. pyGathering system information with uname command: Linux pydb 2.6.18-308. el5 #1 SMP Tue Feb 21 20:05:41 EST 2012 i686 i686 i386 GNU/LinuxGathering diskspace information df command: filesystem Size Used Avail Use % Mounted on/dev/mapper/VolGroup00-LogVol00 37G 3.9G 31G 11%/dev/sda1 99 M 13 M 82 M 13%/boottmpfs 506 M 0 506 M 0%/dev/shm [root @ pydb python] #