subprocess

Python subprocess, mysqldump and pipes

I've got a problem trying to build a easy backup/upgrade database script. The error is in the mysqldump call using subprocess: cmdL = ["mysqldump", "--user=" + db_user, "--password=" + db_pass, domaindb + "|", "gzip", ">", databases_path + "/" + domaindb + ".sql.gz"] print "%s: backup database %s \n\t[%s]" % (domain, domaindb, ' '.join...

How do you return to a sourced bash script?

Hi, I use a script that extends using the bash source feature; #!/bin/bash source someneatscriptthatendsprematurely.sh I would like to be able to return from that script, without breaking the main script. Using exit breaks the main script, return is only valid in functions and experimenting with $(exit 1) does not seem to work eith...

programmatically executing and terminating a long-running batch process in python

Hi guys, I have been searching for a way to start and terminate a long-running "batch jobs" in python. Right now I'm using "os.system()" to launch a long-running batch job inside each child process. As you might have guessed, "os.system()" spawns a new process inside that child process (grandchild process?), so I cannot kill the batch ...

Django app stops working when deployed on Apache ( subprocess runs, but fails )

My Django app stops working when deployed on Apache ( with mod_wsgi ). It runs on a Windows server. The app calls on a windows executable called "rex" ( Alchemy Remote Executor ) which executes a command on another remote windows box. process = subprocess.Popen( ['rex',ip,usr,pwd,command], stdout=subprocess.PIPE, universal_newlines=...

What is the Java equivalent of Python's subprocess.Popen()?

import subprocess import os prefix = os.path.expanduser("~/.bin/kb/") p = subprocess.Popen([(prefix + "koreball"),(prefix + "/data"),'3']) ...

Python subprocess how to determine if child process hangs?

Hello, How do I know is there my child process got hang while operating? ...

Custom standard input for python subprocess.

Hello, I'm running an SSH process like this: sshproc = subprocess.Popen([command], shell=True) exit = os.waitpid(sshproc.pid, 0)[1] This works and opens an interactive terminal. Based on the documentation for subprocess, sshproc is using the script's sys.stdin. The question is: how can I print to stderr or a file what input is bein...

Python subprocess timeout?

Hello is there any argument or options to setup kinda subprocess.Popen(['..'], ..., timeout=20)? Sultan ...

Is there a good python library that provides PGP decryption functionality without the use of a subprocess?

I am looking for a way to decrypt pgp messages in python without the use of a subprocess. I have checked out http://wiki.python.org/moin/GnuPrivacyGuard but none of those solutions worked. Pyme almost worked except I hit a wall when trying to use set_passphrase_cb to avoid any user interaction but couldn't get it working ( http://stackov...

how to keep multiprocessing main process always exists?

I want to achieve a application, to spawn new process execute tasks, basically like below. web----->pyro----->multiprocessing Through web send command,and communicate with pyro, and then pyro spwan new process to handle the task script. What confused me is.. When I send tasks through pyro once, I send another task, is it possible? ...

subprocesses with different working directories problem with python.

I am working under the following project directory. work/project/test/a.py then, inside a.py, I have to use the subprocess.POPEN to launch the process from another directory, work/to_launch/file1.pl, file2.py, file3,..., (note: the file1.pl will call file2.py, file3. etc) e.g. inside a.py, I use subprocess.POPEN("usr/bin/perl ....

subprocess.popen seems to fail when run from crontab

Hi All, probably a daft question but.... I'm running a script from crontab that will just ssh and run a command and store the results in a file. the function that seems to be failing is subprocess.popen Here is the function def _executeSSHCommand(sshcommand,user,node): ''' Simple function to execute an ssh command on a remo...

How to stop python from propagating signals to subprocesses?

I'm using python to manage some simulations. I build the parameters and run the program using: pipe = open('/dev/null', 'w') pid = subprocess.Popen(shlex.split(command), stdout=pipe, stderr=pipe) My code handles different signal. Ctrl+C will stop the simulation, ask if I want to save, and exit gracefully. I have other signal handlers ...

python, subprocess: reading output from subprocess

I have following script: #!/usr/bin/python while True: x = raw_input() print x[::-1] I am calling it from ipython: In [5]: p = Popen('./script.py', stdin=PIPE) In [6]: p.stdin.write('abc\n') cba and it works fine. However, when I do this: In [7]: p = Popen('./script.py', stdin=PIPE, stdout=PIPE) In [8]: p.stdin.write('...

how to have command as input for a shell launched inside a python subprocess

Hello, all, I want to create a GUI python script to launch several processes. All of these processes originally were called by setting up a shell with a perl script (start_workspace.perl), and type the executable file name under the shell. inside, start_workspace.perl, it first set some ENV variables, and then call exec(/bin/bash), wh...

Processing lines of shell command stdout lazily in python

I'm working on a toy language, and I've implemented the ability to stream lines of text from shell commands lazily (as a generator). Currently, my code to do this looks like: #!/usr/bin/env python3 import signal,subprocess,select # suppress 'broken pipe' error messages signal.signal(signal.SIGPIPE, signal.SIG_DFL) def shell_exec(cmd)...

automatically attach a debugger to a new Java sub-process in Eclipse

I hava a Java process that spawns a new JVM using ProcessBuilder etc. While debugging this, is it possible to have Eclipse attach a debugger to the new sub-process? Even better, is there any plugin that will do this automatically when it notices the new child process? I'm told (though haven't seen) that VisualAge used to be able to do t...

Check memory usage of subprocess in Python

Hi all, I'm developing an application in Python on Ubuntu and I'm running external binaries from within python using subprocess. Since these binaries are generated at run time and can go rogue, I need to keep a strict tab on the amount of memory footprint and runtime of these binaries. Is there someway I can limit or monitor the memory u...

Python, using subprocess.Popen to make linux command line call? I'm getting "[Errno 2] No such file or directory"

I'm trying to follow the info I can find about subprocess.Popen as I want to make a linux command line call.. I am trying as below but am getting the error "[Errno 2] No such file or directory". I'm not trying to open a file so I don't understand this error, and it works fine (although with other issues relating to waiting for the proce...

Broken Pipe when calling subprocess.Popen() within a multiprocessing.Process()

I am having an issue when making a shell call from within a multiprocessing.Process(). The error seems to be coming from Git, but I just can't figure out why it only happens from within a multiprocessing.Process(). Note, below is an example to demonstrate what's happening... in real code there is a lot more going on within the Process(...