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

Re: [Condor-users] arguments string with single quotes



Thanks, Ian.

 

I’m actually using a vbs file as my driver, which could have its own parsing quirks.  Incidentally, the way I was determining what is getting passed to my script (as opposed to how my script is parsing it) was by looking at the StarterLog for the associated slot.  

 

My submit file says: arguments = “'subarg1=''val1''' 'subarg2=''val2''' 'subarg3=''val3'''”

 

But the StarterLog for the slot the job got sent to says this: About to exec C:\condor\execute\dir_5672\condor_exec.vbs subarg1=''''val1'''' subarg2=''''val2'''' subarg3=''''val3''''

 

Can I safely assume that what shows up in the StarterLog is what’s actually getting passed, or could there be some additional parsing weirdness in writing the StarterLog?

 

 

 

From: condor-users-bounces@xxxxxxxxxxx [mailto:condor-users-bounces@xxxxxxxxxxx] On Behalf Of Ian Chesal
Sent: Thursday, June 21, 2012 1:33 PM
To: Condor-Users Mail List
Subject: Re: [Condor-users] arguments string with single quotes

 

Hi Sara,

 

I hope someone else on the list can show me that I'm wrong, but if you're using bat files as your driver for a job, command line parsing kind of falls apart. It isn't Condor's fault though -- it's all down to bat file command line argument parsing behaviour.

 

The argument parsing discussed in the Condor docs at http://research.cs.wisc.edu/condor/manual/v7.6/condor_submit.html promises us this:

 

   And yet another example:

 

   arguments = "one ""two"" 'spacey ''quoted'' argument'"

   Produces:

 

   argument 1: one

   argument 2: "two"

   argument 3: spacey 'quoted' argument

 

Let's test this. I have the following in in a file called args.bat:

 

   @echo off

   SET count=1

   :loop

   IF NOT "%1"=="" (

               echo ARG %count%: %1

               SET /A count+=1

               SHIFT 

               GOTO :loop

   )

 

 

All we want is consistent behaviour between the command line call and the call done via Condor. So let's check the command line first:

 

   C:\temp\args>.\args.bat one ""two"" 'spacey ''quoted'' argument'

   ARG 1: one

   ARG 2: ""two""

   ARG 3: 'spacey

   ARG 4: ''quoted''

   ARG 5: argument'

 

That isn't what the documentation promised us, but it's a base line for the run and it shows how odd parsing is with bat files. I'll submit it with:

 

   universe   = vanilla

   executable = c:/temp/args/args.bat

   arguments  = "one ""two"" 'spacey ''quoted'' argument'"

   requirements = OpSys != "Linux" && Arch =!= Undefined && Disk > 0 && Memory > 0

   run_as_owner = false

   output = $(cluster).$(process).out

   error  = $(cluster).$(process).err

   log    = $(cluster).log

   should_transfer_files   = if_needed

   when_to_transfer_output = on_exit

   queue 1

 

We'd expect the same output, but no: the job fails. The error message is:

 

   C:\temp\args>type 17.0.err

   The system cannot find the path specified.

 

   C:\temp\args>type 17.0.out

 

Let's try again, this time with:

 

   arguments  = "one ''two'' three"

 

Nope:

 

   C:\temp\args>type 18.0.out

   ARG 1: one

   ARG 2: two

   ARG 3: three

 

How about:

 

   arguments = "one 'two three' four"

 

Errors out with:

 

   C:\temp\args>type 19.0.err

   'c:/temp/args/args.bat" one "two' is not recognized as an internal or external command,

   operable program or batch file.

 

Ouch.

 

If we switch to an args.py file that looks like this:

 

   import sys

   count = 1

   while count < len(sys.argv):

               print "ARG %d: %s" % (count, sys.argv[count])

               count = count + 1

   exit(0)

 

things are MUCH better.

 

For the case:

 

   executable = c:/temp/args/args.py

   arguments  = "one 'two three' four"

 

I get:

 

   C:\temp\args>type 20.0.out

   ARG 1: one

   ARG 2: two three

   ARG 3: four

 

Which grouped the "two three" argument together as it should.

 

For the case:

 

   executable = c:/temp/args/args.py

   arguments  = "one ""two"" 'spacey ''quoted'' argument'"

 

I get:

 

   C:\temp\args>type 21.0.out

   ARG 1: one

   ARG 2: "two"

   ARG 3: spacey 'quoted' argument

 

Which matches what we were promised we'd get in the Condor documentation.

 

If it's possible, I'd avoid using bat files if you need to handle complicated, quoted command line arguments to your jobs.

 

Regards,

- Ian

 

---

Ian Chesal

 

Cycle Computing, LLC

Leader in Open Compute Solutions for Clouds, Servers, and Desktops

Enterprise Condor Support and Management Tools

 

http://www.cyclecomputing.com

http://www.cyclecloud.com

http://twitter.com/cyclecomputing

 

On Thursday, 21 June, 2012 at 2:59 PM, Triplett, Sara wrote:

I’m having trouble with the proper syntax for including single quotes in an arguments string in a submit file.  I’m trying to pass an arguments string that looks like this:

 

subarg1='val1' subarg2='val2' subarg3='val3'

 

Here’s what I’ve tried so far and what the result was:

 

arguments = “'subarg1=''val1''' 'subarg2=''val2''' 'subarg3=''val3'''” (this seems consistent with the Condor Manual)

result: subarg1=''''val1'''' subarg2=''''val2'''' subarg3=''''val3'''' (each pair of single quotes turns into 4 single quotes)

 

arguments = “subarg1=''val1'' subarg2=''val2'' subarg3=''val3''”

result: subarg1= val1 subarg2= val2 subarg3= val3 (each pair of single quotes becomes a space)

 

arguments = “subarg1='val1' subarg2='val2' subarg3='val3'”

result: subarg1=val1 subarg2=val2 subarg3=val3 (all single quotes are removed)

 

Does anyone know what syntax I should use to produce my desired string?  I am running Condor 7.6.3.

 

Thanks,

Sara

==============================================================================
The information in this e-mail and any attachments are for the sole use of the intended recipient and may contain privileged or confidential information. Delivery to other than the intended recipient shall not be deemed to waive any privilege. Any unauthorized use, disclosure, copying or distribution of this message or attachment is strictly prohibited. If you believe that you have received this e-mail in error, please contact the sender immediately and delete the e-mail and all of its attachments.
==============================================================================

_______________________________________________

Condor-users mailing list

To unsubscribe, send a message to condor-users-request@xxxxxxxxxxx with a

subject: Unsubscribe

You can also unsubscribe by visiting

 

The archives can be found at: