newbie: popen question

thebiggestbangtheory at thebiggestbangtheory at
Wed May 27 21:10:22 EDT 2009

hello everyone :-),
                         I am a newbie to python. I am trying to run a
bash script from within a python program. I would greatly appreciate
any pointers/comments about how to get around the problem I am facing.

I want to run  bash script: from within a python program. needs to be run like so from the command line
$ sudo arg1 arg2

I read up on some documentation but am not very clear about how to use
popen. I want to relegate the shell to a background process, but it
needs to accept the sudo passwd too!

I have tried
p = subprocess.Popen(['/bin/bash', 'sudo '+mypath+' '+arg1+'
I tried some code from

nothing really happens when this executes, the PIPE option pshes it to
the background and I can't push in the sudo passwd. Can someone please
give me an idea of how to go about this.

To recap, I want to run a shell script, which needs to be started with
sudo, and then push it into the background.


More information about the Python-list mailing list