From owner-freebsd-python@FreeBSD.ORG Thu Aug 19 16:30:38 2004 Return-Path: Delivered-To: freebsd-python@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D92BB16A4CE for ; Thu, 19 Aug 2004 16:30:38 +0000 (GMT) Received: from diligence.flag.rootnode.com (adsl-65-67-81-98.dsl.ltrkar.swbell.net [65.67.81.98]) by mx1.FreeBSD.org (Postfix) with ESMTP id 81E3043D3F for ; Thu, 19 Aug 2004 16:30:38 +0000 (GMT) (envelope-from joe@osoft.us) Received: from [10.0.1.105] (coherence.flag.rootnode.com [10.0.1.105]) by diligence.flag.rootnode.com (Postfix) with ESMTP id 05EA3D4AE; Thu, 19 Aug 2004 11:30:34 -0500 (CDT) Message-ID: <4124D5FF.3010005@osoft.us> Date: Thu, 19 Aug 2004 11:31:59 -0500 From: Joe Koberg User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Max Russell References: <20040819095330.14270.qmail@web25404.mail.ukl.yahoo.com> In-Reply-To: <20040819095330.14270.qmail@web25404.mail.ukl.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-python@freebsd.org Subject: Re: startfile() equivalent X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Aug 2004 16:30:39 -0000 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