[Tutor] Running multiple python scripts from one python scripts

Mats Wichmann mats at wichmann.us
Thu Oct 24 16:28:22 EDT 2019


On 10/24/19 7:35 AM, ose micah via Tutor wrote:
> Hello Alan,
> I am having issues in running multiple python scripts in one same program. The reason is that, I am creating this mini scripts in the main (master) scripts, then at the end run them all sequentially.
> here is a sample.
> 
> 
> 
> import osimport sys...............os.system('python /tmp/delete_line3.py')os.system('python /tmp/create_20lines.py')os.system('python /tmp/delete_ON2_.py')os.system('python /tmp/create_50.py')
> 
> when I tried this, only the first script "delete_line3.py" ran and quitted. The rest did not execute.
> Next I tried this program.
> import fileinputimport subprocess as sp............... extProc = sp.Popen(['python','/tmp/delete_line3.py'])sp.Popen.terminate(extProc)extProc = sp.Popen(['python','/tmp/create_20lines.py'])sp.Popen.terminate(extProc)extProc = sp.Popen(['python','/tmp/ delete_ON2_.py'])sp.Popen.terminate(extProc)extProc = sp.Popen(['python','/tmp/ create_50.py'])sp.Popen.terminate(extProc)
> 
> it did not work at all.
> is there anything that I can do to

your formatting in the email is all mangled, rally hard to read.

you almost certainly don't want to be calling "terminate".
call "wait" to wait for the subprocess to finish, or "communicate" to 
interact with it (possibly send it data, plus collect back the output 
and error streams from it)




More information about the Tutor mailing list