Date: Thu, 19 Aug 2004 11:31:59 -0500 From: Joe Koberg <joe@osoft.us> To: Max Russell <max_russell2000@yahoo.co.uk> Cc: freebsd-python@freebsd.org Subject: Re: startfile() equivalent Message-ID: <4124D5FF.3010005@osoft.us> In-Reply-To: <20040819095330.14270.qmail@web25404.mail.ukl.yahoo.com> References: <20040819095330.14270.qmail@web25404.mail.ukl.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Max Russell wrote: >Also- I do not launch x-mame from the GUI, I use a >script (in Perl) to select and choose my game of >choice. So I suppose what I am looking for is >something that allows me to use a *nix system command >from within a Python script. > > > http://www.python.org/doc/lib/os-process.html If you just want to launch a command: import os os.system('unix shell command here') If you need the stdin/stdout/stderr channels from the process you launched, to communicate with it over stdio: import os stdin, stdout, stderr = os.popen3('unix shell command here') # now you can do i.e. stdin.write('data going to program') If you want the new process to replace your python process (exec): import os os.execvp(programname, (arg1, arg2, arg3, ...)) # os.execvp doesn't return - so you'll never reach this comment If you want to start the process and wait around for its return value: import os returnval = os.spawnvp(os.P_WAIT, programname, (arg1, arg2, ...)) or if you want to start it and get its PID immediately: import os pid = os.spawnvp(os.P_NOWAIT, programname, (arg1, arg2, ...)) Thanks for using Python and FreeBSD! Joe Koberg joe at osoft dot us
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4124D5FF.3010005>