January 28th, 2005, 01:14 PM
Making Python execute a command line in UNIX
How can I have a script, let's say 'go.py' execute another script called 'run.py'?
I just want 'go.py' to perfom the same function as when you type a command in UNIX like below:
thanks for the help!
January 28th, 2005, 03:01 PM
Just a quick suggestion, you could use distutils. from distutils.core import run.py. You can learn all about this at python.org's tutorial. Also, with from distutils.core import run.py, yes, run.py would have to be in the same Directory as go.py.
January 28th, 2005, 03:30 PM
or if you want to just run it like unix does you could do
Inside the "" you can put anything you want, it will go to shell and execute how shell would execute is, so if you put say "echo 'hehe'" it would put hehe to the screen like shell would.
from os import system
January 28th, 2005, 04:02 PM
Does system() work like Shell() works in VB6? If you know VB6. For example, if i did system(notepad) would it open notepad.exe through system32 (on windows)?
January 28th, 2005, 07:24 PM
yes it does, everything that you would enter into cmd it will run exactly the same way with the system function in python.
January 29th, 2005, 11:42 AM
If your running Python 2.4 then you should be using the subprocess module rather than os.system() etc. Heres a link to the modules documentation.
Hope this helps,
February 1st, 2005, 09:25 PM
these are very heplful