Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49697 > unrolled thread

Python - forking an external process?

Started byVictor Hooi <victorhooi@gmail.com>
First post2013-07-02 20:47 -0700
Last post2013-07-03 12:55 +0200
Articles 6 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Python - forking an external process? Victor Hooi <victorhooi@gmail.com> - 2013-07-02 20:47 -0700
    Re: Python - forking an external process? rusi <rustompmody@gmail.com> - 2013-07-02 20:59 -0700
      Re: Python - forking an external process? Victor Hooi <victorhooi@gmail.com> - 2013-07-02 21:11 -0700
        Re: Python - forking an external process? rusi <rustompmody@gmail.com> - 2013-07-02 21:22 -0700
    Re: Python - forking an external process? Roy Smith <roy@panix.com> - 2013-07-03 00:17 -0400
    Re: Python - forking an external process? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-07-03 12:55 +0200

#49697 — Python - forking an external process?

FromVictor Hooi <victorhooi@gmail.com>
Date2013-07-02 20:47 -0700
SubjectPython - forking an external process?
Message-ID<14be21de-2ceb-464a-a638-dce0368ab9e7@googlegroups.com>
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 <xyz>, 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?

Cheers,
Victor

(I did see this SO post - http://stackoverflow.com/questions/6011235/run-a-program-from-python-and-have-it-continue-to-run-after-the-script-is-kille, but it's a bit older, and I was going to see what the current idiomatic way of doing this is).

[toc] | [next] | [standalone]


#49698

Fromrusi <rustompmody@gmail.com>
Date2013-07-02 20:59 -0700
Message-ID<3d55a01e-379d-490e-8573-548d2ac21db5@googlegroups.com>
In reply to#49697
On Wednesday, July 3, 2013 9:17:29 AM UTC+5:30, Victor Hooi wrote:
> 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 <xyz>, I then want to run ssh to a host, handover 
> control back to the user, and have my script terminate.

Seen Fabric? 
http://docs.fabfile.org/en/1.6/

Recently -- within the last month methinks -- there was someone who posted a supposed improvement to it (forget the name)

[toc] | [prev] | [next] | [standalone]


#49699

FromVictor Hooi <victorhooi@gmail.com>
Date2013-07-02 21:11 -0700
Message-ID<fe220468-75ba-4614-a32e-1e3e58a687c0@googlegroups.com>
In reply to#49698
Hi,

Hmm, this script is actually written using the Cliff framework (https://github.com/dreamhost/cliff).

I was hoping to keep the whole approach fairly simple, without needing to pull in too much external stuff, or set anything up.

There's no way to do it with just Python core is there?

Also, what's this improvement you mentioned?

Cheers,
Victor

On Wednesday, 3 July 2013 13:59:19 UTC+10, rusi  wrote:
> On Wednesday, July 3, 2013 9:17:29 AM UTC+5:30, Victor Hooi wrote:
> 
> > 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 <xyz>, I then want to run ssh to a host, handover 
> 
> > control back to the user, and have my script terminate.
> 
> 
> 
> Seen Fabric? 
> 
> http://docs.fabfile.org/en/1.6/
> 
> 
> 
> Recently -- within the last month methinks -- there was someone who posted a supposed improvement to it (forget the name)

[toc] | [prev] | [next] | [standalone]


#49702

Fromrusi <rustompmody@gmail.com>
Date2013-07-02 21:22 -0700
Message-ID<35c74a51-5fab-4750-a8e4-7022c7cde19f@googlegroups.com>
In reply to#49699
On Wednesday, July 3, 2013 9:41:32 AM UTC+5:30, Victor Hooi wrote:
> Also, what's this improvement you mentioned?

See thread
http://mail.python.org/pipermail/python-list/2013-June/650550.html

[toc] | [prev] | [next] | [standalone]


#49701

FromRoy Smith <roy@panix.com>
Date2013-07-03 00:17 -0400
Message-ID<roy-8EE522.00170503072013@70-1-84-166.pools.spcsdns.net>
In reply to#49697
In article <14be21de-2ceb-464a-a638-dce0368ab9e7@googlegroups.com>,
 Victor Hooi <victorhooi@gmail.com> wrote:

> 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 <xyz>, 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?

I suspect you are trying to reinvent fabric.  It is designed to do 
exactly these things (in particular, handling all the really complicated 
stuff about ssh).

See http://docs.fabfile.org/

[toc] | [prev] | [next] | [standalone]


#49719

FromAntoon Pardon <antoon.pardon@rece.vub.ac.be>
Date2013-07-03 12:55 +0200
Message-ID<mailman.4160.1372848957.3114.python-list@python.org>
In reply to#49697
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 <xyz>, 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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web