When create a program with Python, we can use a script Python Run External Program. We can use this script in command line or in program. Before we can use a command to Python run external program, we must import class in python which handle this command. We can use import os class in our script. So, add this import command in your script/command line :
After we import os class, we can use command os.system or os.popen to Python run external program. We use os.system command if we want to run external program with Python. This is example how to use command ls (list of directory and file in Linux) with Python run external program :
This command will execute command ls-l in linux and show output from this command. If we want to capture output from Python run external program, we can use command os.popen. This is example how to use Python run external program with function os.popen :
In : listfile = os.popen("ls *.zip","r").read() In : listfile Out: 'LargeDataSeismic_CODE.zip\nobspy.segy-0.4.5.zip\n'
This is a simple python scripts how to Python run external program or application.Source : http://www.frihost.com/forums/vt-62880.html