Hi
I am having problems using subprocess.Popen.

Here is a small script I have written

from subprocess import Popen
import os
global p
def executeProcess():
	cmd = "ls -l /home"
	global p
	p = Popen(cmd)
	#os.system (cmd)

This works only once in a while. I keep getting the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kkj/CNU/LINUX/bin/Runtime/CNUSubprocess.py", line 10, in executeProcess
    p = Popen(cmd)
  File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
    errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1051, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

It works if I use os.system, but I want to use Popen

Also how can I run a bash script like "source" using Popen ? I tried :

os.system (" source .../cshrc")

and I got error messages like setenv : command not found.

Can someone tell me what I'm missing?

Ok. But does call open as a separate process? I used ' ls -l ' only as an example. I want to be able to run a separate application as a child process and use its process id.

Hi, I also want to be able to "source" from within a python script... any more information found on this?

If you want to source .bash_profile for example, it should work fine. Try it for yourself, but be sure to use shell=True, as it should be done through the shell.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.