problem with single-quote and double-quote when using subprocess.
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Tue Nov 4 07:24:22 EST 2008
On Tue, 04 Nov 2008 03:26:21 -0800, MRAB wrote:
> On Nov 3, 10:47 pm, Evan <xdi... at gmail.com> wrote:
>> 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
>
> It looks like there are _4_ items on the command line:
>
> goset
> -f
> ' "%s %s" name addr '
> file_name
>
> so the call should be:
>
> p = subprocess.Popen(["goest", "-f", "' \"%s %s\" name addr '",
> "file_name"], shell=True)
The argument after '-f' doesn't have the single quotes at both ends.
They tell the shell that it is just one argument and the shell removes
them before calling ``goset`` (or ``goest``).
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list