Path: csiph.com!usenet.pasdenom.info!aioe.org!newsfeed.tele2net.at!newsfeed.utanet.at!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.238.0.231.MISMATCH!news.skynet.be!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'received:134': 0.05; 'subject:Python': 0.06; 'host,': 0.09; 'option,': 0.09; 'subject:process': 0.09; 'terminates': 0.09; 'python': 0.11; 'exit.': 0.16; 'fork': 0.16; 'ssh': 0.16; 'terminate.': 0.16; 'command': 0.22; 'python?': 0.22; 'header:User-Agent:1': 0.23; '(or': 0.24; 'script': 0.25; 'certain': 0.27; 'header:In-Reply- To:1': 0.27; 'external': 0.29; 'run': 0.32; 'something': 0.35; 'done': 0.36; 'doing': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'example,': 0.37; 'starting': 0.37; 'to:addr:python- list': 0.38; 'launch': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 'back': 0.62; 'finish': 0.65; 'within': 0.65; 'user,': 0.69; 'wish': 0.70; 'attractive': 0.81; 'pardon': 0.84; 'victor': 0.84; 'family.': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EAKYC1FGGuA9G/2dsb2JhbABawUGCcIEWgxgBBXgRCyEWDwkDAgECAUUTCAKIC7JuiAePbBaDVwOXSoYOizeDEw Date: Wed, 03 Jul 2013 12:55:55 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python - forking an external process? References: <14be21de-2ceb-464a-a638-dce0368ab9e7@googlegroups.com> In-Reply-To: <14be21de-2ceb-464a-a638-dce0368ab9e7@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372848957 news.xs4all.nl 15874 [2001:888:2000:d::a6]:53208 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49719 Op 03-07-13 05:47, Victor Hooi schreef: > Hi, > > I have a Python script where I want to run fork and run an external command (or set of commands). > > For example, after doing , I then want to run ssh to a host, handover control back to the user, and have my script terminate. > > Or I might want to run ssh to a host, less a certain textfile, then exit. > > What's the idiomatic way of doing this within Python? Is it possible to do with Subprocess? > If I understand correctly that you want something done in python and then wish to finish python and give control to an other program. I would use an external script that would first launch the python program and then the other program. If for some reason this is a less attractive option, you can use the os.exec family. That terminates the python program will starting up an other program. -- Antoon Pardon