By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,514 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,514 IT Pros & Developers. It's quick & easy.

problem with quote and single-quote when using "subprocess"

P: n/a
Hello -

i'm trying to call subprocess.popen on the 'command-based' function in
linux. When I run the command from the shell, like so:

goset -f ' "%s %s" name addr ' file_name

it works fine

however when I try to do it in python like so:

p = subprocess.Popen(["goest",'-f \'\"%s %s\" name addr\' ',
'file_name'], shell=True)

It always failed.

I also try like so:

p = subprocess.Popen(["goest","-f '\"%s %s\" name addr' ",
'file_name'], shell=True)

It also failed.

Does anybody have a good suggestion for this matter? thanks in
advance.

Evan
Nov 3 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mon, 03 Nov 2008 14:45:22 -0800, Evan wrote:
Hello -

i'm trying to call subprocess.popen on the 'command-based' function in
linux. When I run the command from the shell, like so:

goset -f ' "%s %s" name addr ' file_name

it works fine

however when I try to do it in python like so:

p = subprocess.Popen(["goest",'-f \'\"%s %s\" name addr\' ',
'file_name'], shell=True)

It always failed.
Yes because ``goset`` (I guess "goest" was a typo!?) has no option
`'-f '"%s %s" name addr' `. And you should decide if you want to split
the arguments yourself or if you want to use the shell. Mixing both
doesn't make much sense.

If *you* split the arguments, the call should look like this:

p = subprocess.Popen(['goset', '-f', ' "%s %s" name addr ', 'file_name'])

Ciao,
Marc 'BlackJack' Rintsch
Nov 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.