top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Python - forking an external process?

0 votes
30 views

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 Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes
answer Jul 3, 2013 by anonymous
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?
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","filename.py"],stdout=PIPE)

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

Here,
Filename.py(Child 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.

+3 votes

I need python code snippet for LTE/UMTS for automation testing.Example of scenario looking for LTE attach ,detach, MO/MT call .
I am looking for UE side scripts.

+2 votes

I am using the Linux system with python, i am running the following script

#!/usr/bin/python

import threading

import time

import sys
import subprocess
import datetime
import os
import time
import logging

proc1=subprocess.Popen("/root/Desktop/abc.py","64","abc",shell=True,stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

In this script i am calling the other script named abc.py which is located on the desktop with 64 and abc as its arguments I am getting the following error

File "/usr/lib64/python2.6/subprocess.py", line 589, in __init__
 raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer

Can someone help me?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...