Python: Spawn New Minimized Shell -
i attempting to launch python script within python script, in minimized console, return control original shell.
i able open required script in new shell below, it's not minimized:
#!/usr/bin/env python import os import sys import subprocess pytivopath="c:\pytivo\pytivo.py" print "testing: open new console" subprocess.popen([sys.executable, pytivopath], creationflags = subprocess.create_new_console) print raw_input("press enter continue...")
further, need able later remotely kill shell original script, suspect i'll need explicit in naming new process. correct?
looking pointers, please. thanks!
note: python27 mandatory application. need work on mac , linux.
do need have other console open? if commands sent, i'd recommend using popen.communicate(input="shell commands") , automate process you.
so write along lines of:
# commands pass subprocess (each command separated newline) commands = ( "command1\n" + "command2\n" ) # process py_process = subprocess.popen(*yourprocess_here*, stdin=pipe, shell=true) # feed process needed input py_process.communicate(input=commands) # terminate when finished py_process.terminate()
the code above execute process specify , send commands won't open new console.
Comments
Post a Comment