saga-project / BigJob

SAGA-based Pilot-Job Implementation for Compute and Data
http://saga-project.github.com/BigJob/
Other
19 stars 8 forks source link

Special Characters in CUD Argument Strings #163

Open melrom opened 10 years ago

melrom commented 10 years ago

The way BigJob is currently written, a task description's 'arguments' field is parsed as just a python string.

For example:

        task_desc.executable = ['/bin/echo']
        task_desc.arguments = ['I am task number $TASK_NO','; exec /bin/echo dog' ]

is equivalent on command line:

(python)login1$ /bin/echo 'I am task number 1' ; exec /bin/echo dog I am task number 1 dog

Because of this, a user must know that is completely a string, in order to put other characters, such as quotation marks, single quotation marks, semicolons, etc. into their arguments.

For example, in python, to print something with quotation marks, I can say:

print ''' "This is something in quotation marks" '''

For an analogous BigJob example, I will illustrate with semicolon.

On command line, I can type:

(python)login1$ /bin/echo '2;1' 2;1

But in BigJob, I can't do this in a way that is immediately apparent to the end-user, because of the way the arguments are just appended strings. So

        task_desc.executable = ['/bin/echo']
        task_desc.arguments = "2;1"

Produces an stdout of 2 and a stderr of "-bash: 1: command not found"

Similarly,

task_desc.arguments = " '2;1' "

has the same result.

In order to actually print 2;1, I need to use triple quotes (akin to what I did above in order to print a string with quotations):

        task_desc.executable = ['/bin/echo']
        task_desc.arguments = ''' "2;1" '''

This will actually print 2;1 (no quotes) to stdout. This is sort of a python nuance, but, the API docs should be very clear that there is no magic with the arguments list - it is just passed to command line as a pythonic string, or we should implement something to operate otherwise in the code. Either solution is fine. This is not a pressing matter. I was just trying to document it for future reference in case any users encounter this issue.