top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Python - forking an external process?

0 votes

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?

posted Jul 3, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
answer Jul 3, 2013 by anonymous
This script is actually written using the Cliff framework (

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?
Similar Questions
+2 votes

I want to use the stdout of child process as an input of another thread, but some how I am not able to read the stdout. Using Popen I have created a child process and stdout of it I have redirected to PIPE (because I don't want that to be printed on with my main process). Now using this statement,"Line=Proc.stdout.readline()" I want to read stdout of child process and I have to do operation on that. but somehow i am not able to read from stdout of child process.

Following is the code snapshot -

Proc = Popen(["python.exe",""],stdout=PIPE)

while True:
            Line = Proc.stdout.readline()
            print Line

Here, process) is continuously printing "Hello World!!" in place of reading stdout of child process.

+2 votes

I have a long-running python/CherryPy Web App server process that I am running on Mac OS X 10.8.5. Python 2.7.2 running in 32-bit mode (for now, I have the code in place to change over to 64 bit, but need to schedule the downtime to do it). On the 6th of this month, during normal operation from what I can tell, and after around 33 days of trouble-free uptime, the python process crashed with a SIGABRT. I restarted the process, and everything looked good again until yesterday, when it again crashed with a SIGABRT. The crash dump the system gave me doesn't tell me much, other than that it looks like python is calling some C function when it crashes.

Can anyone give me some hints as to how to track down the cause of this crash? It's especially problematic since I can't mess with the live server for testing, and it is quite a while between crashes, making it difficult, if not impossible, to reproduce in testing.

+1 vote

I want to build a class that perform various functions to the content(or lines) of any given file. I want to first include the opening and reading file function into that class, then add other methods.

Here is what I wrote for opening file and reading the lines:

class FileOpration:
 def __init__(self,name): = name
 self.filename =
 def readAllline(self):

file1 = FileOpration("myfile.txt")
print file1.filename
allines = file1.readAllline()
print allines

I define variable because I want to store the specific file that I read. This works fine by the test code of print file1.filename. I saw "myfile.txt" on the terminal output.

However, the readAllline() method dose not work. The code only give me "None" as the output on terminal

0 votes

I wish to use HPs dvd550s-H03 8 with Puppy precise based on Ubuntu 12.04. Currently it does not detect my external us.b drive. Can someone point me in the right direction?

–1 vote

R has the function edit() which allows the editing of the definition of a function. Does python have something similar so that users can edit python functions on the fly?