This example only works on Python 2.6 or later.
""" StartThreadForSciLab.py """ import subprocess # write scilab script into a file. # this will be executed by Scilab f = open('C:\\tmp\\scilabTest.sce', 'w') cmds = """printf('hello!') x = input("Press return to continue:","string") exit """ f.write(cmds) f.close # start up Scilab and retain a handle to control and monitor sciLabProcess = subprocess.Popen( '"C:\\Program Files\\scilab-5.1.1\\bin\\WScilex.exe" -f c:\\tmp\\scilabTest.sce ', bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0) # wait for process to exit, or terminate it while sciLabProcess.poll() is None: print 'still running' reply = raw_input("Kill process ? (type yes) ") if reply.strip()=='yes': sciLabProcess.terminate()