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

Re: [Condor-users] condor_chirp - How to escape special characters in classads?

On Jan 5, 2012, at 4:42 PM, Felix Wolfheimer wrote:

> I assume this is on Unix?
> ---> Actually, on both Windows and Unix.
> condor_chirp set_job_attr MyAttributes '"A String with spaces"'
> ---> Thanks for the tip. This worked perfectly (I just tried on Unix so
> far but will try on Windows later). One thing I still can't do with this
> is the following: Let's say I want that the MyAttributes classad has the
> value '"foo" "bar"' (including the quotes). The problem now are the two
> quotes around the space in the middle. I can again escape them like
> this:
> condor_chirp set_job_attr MyAttributes '"foo\" \"bar"'
> but in this case the classad contains the escape character \ as well.
> When I don't use the escape character the classad is simply not set at
> all. Is there a way how an arbitrary string can be copied to a classad
> just as it is? Let's say I want to have something like this:
> condor_chirp set_job_attr JobRdpShell '"C:\Program Files (x86)\RDPTools
> \RDPsession.exe -f -s "my shell.exe"'
> Where "C:\Program Files (x86)\RDPTools\RDPsession.exe -f -s "my
> shell.exe" should be the value of the classad.

I think I should clarify the classad attribute syntax. An attribute value can be a single literal value (a string, number, or boolean) or an expression. You can't have a pair of strings as an attribute value.* When setting a string value, any double-quotes in the string need to be escaped with backslashes. The escaping backslashes will appear when you print the full classad (i.e. when using condor_q -l). But the escaping backslashes won't be in the string value itself. For example, if you run condor_q -format '%s\n' MyAttributes, you won't see the escaping backslashes.

* Starting in Condor 7.5.2, attribute values can be a list of literals and expressions, like this:
   MyAttributes = { "foo", 3, A+B }
You can reference the items using C-like array indexing:
   Foo = MyAttributes[0]
This list syntax isn't used in any attribute values that Condor sets, and Condor versions prior to 7.5.2 won't recognize it.

Thanks and regards,
Jaime Frey
UW-Madison Condor Team