Faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 5 people (100%) answered Yes
Recently 2 of 2 people (100%) answered Yes


Can I initiate script B at the end of script A?

Jun 25th, 2000 20:27
unknown unknown, David Bolen

Try the os.exec* functions in the os module.  It sounds pretty much
like what you want to do.  The exec* functions replace the current
running executable with another executable - only one process slot is
involved, and the original executing code does not exist following the
exec call.
Note however that since you'll be replacing your current process, you
actually need to exec python giving it the new script as an argument,
rather than just directly-exec()ing the script.
You can use sys.executable to determine the python that is executing
the current script and just exec() that with an argument of the new
You don't note your platform, but I believe this is documented for
both Windows and Unix.