473,507 Members | 12,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with single-quote and double-quote when using subprocess.

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
3 6504
On Nov 4, 8:47*am, Evan <xdi...@gmail.comwrote:
It always failed.
It also failed.
Does anybody have a good suggestion for this matter? thanks in
advance.
What do you mean by "it failed"? It always helps to paste the actual
error message you received.
Nov 4 '08 #2
On Nov 3, 10:47*pm, Evan <xdi...@gmail.comwrote:
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.
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)

(Untested)
Nov 4 '08 #3
On Tue, 04 Nov 2008 03:26:21 -0800, MRAB wrote:
On Nov 3, 10:47Â*pm, Evan <xdi...@gmail.comwrote:
>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
Nov 4 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7143
by: L Major | last post by:
Hi Unfortunately, I am limited to using tables for part of my current project. I have a form that spans across a number of TR and TD in the shape of checkboxes. Doctype is XHTML 1.0...
117
7102
by: Peter Olcott | last post by:
www.halting-problem.com
15
3602
by: Hemant Shah | last post by:
Folks, We have an SQL statement that was coded in an application many years ago (starting with DB V2 I think). When I upgraded to UDB 8.2, the optimizer does not use optimal path to access the...
15
3802
by: Andrew Maclean | last post by:
I guess this problem can be distilled down to: How do I search through a string, find the first matching substring, replace it, and continue through the string doing this. Can replace_if() be used...
9
2113
by: Ed Gonen | last post by:
Hi, I have the following problem. I've created 2 WebServices (A and B) that reference to the same assembly - Credentials. Each WebService (A and B) expose method GetCredentials that returns the...
3
2043
by: Joe Fawcett | last post by:
Dear All We have an application where users login, their name/password details are stored in a table, and now we want to add a third party bulletin board that lives in its own virtual directory....
5
2245
by: Jason | last post by:
I am having a rounding problem in a value i am trying to display in VB.NET. If I have the following code: Dim x As Single = 2726.795 Dim y As Single = Math.Round(2726.795, 2) Dim s as String =...
4
2041
by: Keeper | last post by:
class object (COM-object) return dimension "System.Single". problem: Object o; // object = VARIANT o = comclass.GetData(); Single dm = (Single) o; // Error, problem convertation Help!!!
36
4753
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
0
1272
by: boeledi | last post by:
I'm new in GDI programming and I am facing the following problem. I try to dynamically create "thumbnail"-like images (JPEG) in which I need to draw text. This works fine, except that the text is...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.