[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] Parsing quoted arguments in Condor





Wei Wang wrote:

Hi all,

I tried two cases:

#1. arguments = "-a a_value -b '""b_mod -b_op1 b_op1_value""'", two double-quotes to escape the double-quote, a pair of single-quote to make sure the whitespaces are part of the argument.


This is the correct syntax to produce the following arguments:

Arguments #1
arg1: -a
arg2: a_value
arg3: -b
arg4: "b_mod -b_op1 b_op1_value"


I appologize that in my earlier example I forgot to insert repeated double quotes as required by condor_submit.



#2. arguments = "-a a_value -b '''""b_mod -b_op1 b_op1_value""'''", suggested by J.K.


I think John was under the impression that you wanted literal single quotes in your arguments. His suggestion produces the following arguments:

arg1: -a
arg2: a_value
arg3: -b
arg4: '"b_mod -b_op1 b_op1_value"'

However, I don't think that is what you want.



Both are leagal but both had the problem that "b_mod -b_op1 b_op1_value" can't be parsed for "b_mod" further after the whole string is treated as one argument for the main program.


Unfortunately, I can't understand your statement above. All condor can do is influence the argv[] array that gets passed to main() in your program. If the argv that you want is like #1 above, then the suggested arguments string is what you want.

When you say that you want the arguments:

-a a_value -b "b_mod -b_op1 b_op1_value"


passed to your program. Are you actually saying that this is what you type on the command line of a unix shell? If so, then the double quotes are _not_ part of the argv array sent to your program and Arguments #1 above is _not_ what you want. All common unix shells interpret double quotes specially and do not just pass them verbatim on to the program. The above arguments in common unix shells such as bash or tcsh produce the following arguments to the program:

Arguments #2

arg1: -a
arg2: a_value
arg3: -b
arg4: b_mod -b_op1 b_op1_value


To produce those arguments with condor, you would put the following in the submit file:

arguments = "-a a_value -b 'b_mod -b_op1 b_op1_value'"


According to the logfiles of the Condor jobs, it seems that Condor decides to put in pairs of single-quotes: "b_mod' '-b_op1' 'b_op1_value", which makes sure that the string "b_mod -b_op1 b_op1_value" is treated by Condor as one argument, which is what we want.


When condor displays argument strings in its logs, it may choose to represent them in an equivalent but different way from how you entered them into the submit file. This is expected.

But this caused the problem of parsing "b_mod -b_op1 b_op1_value" for the module "b_mod". We want "-b_op1 b_op1_value" to be the arguments of "b_mod" but Condor's single-quote pairs destroyed this.


I suspect that we are talking past each other. If you still have problems, I just noticed for the first time that not only are you and I in the same institution--we're in the same department! How embarrassing. Drop by my office (Chamberlin 3215) any morning if you need more help. I'm the one who wrote the "new" argument parser in condor. The syntax was constrained in several ways and is therefore a little quirky, but I am confident, at least in unix, that any argument array can be represented, unless it contains characters forbidden by the current implementation of the schedd's ClassAd log (e.g. newlines). In windows, things are a little more hazy, because programs construct their own arguments array (if they construct one at all), and it is therefore up to the program to decide how to interpret the arguments string.

--Dan