You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bash, "-c", "source /tmp/init.sh ; /bin/sort '-s' '-k' '3' '-t' '\t'"
(note I use , to separate the arguments, in total two arguments are passed to bash)
which will then be translated into
d #15300 [ 0.06] * # Script:
d #15300 [ 0.06] | #!/bin/bash
d #15300 [ 0.06] | bash '-c' 'source /tmp/init.sh ; /bin/sort '-s' '-k' '3' '-t' ' ''
However this fails with:
/bin/sort: option requires an argument -- 't'
Try '/bin/sort --help' for more information.
I believe what happens internally is that bash -c treats source /tmp/init.sh ; /bin/sort as the first string and as per documentation everything after becomes an argument:
If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
#!/usr/bin/env pythonimportdrmaaimportosdefmain():
error_log=os.path.join(os.getcwd(), 'error.log')
withdrmaa.Session() ass:
print('Creating job template')
jt=s.createJobTemplate()
jt.remoteCommand="/bin/bash"jt.args= [ '-c', "/bin/sort '-s' '-k' '3' '-t' '\t'" ]
jt.errorPath=":"+error_logjobid=s.runJob(jt)
print('Your job has been submitted with ID {0}'.format(jobid))
retval=s.wait(jobid, drmaa.Session.TIMEOUT_WAIT_FOREVER)
print('Job: {0} finished with status {1}'.format(retval.jobId, retval.exitStatus))
withopen(error_log, 'r') asfin:
print(fin.read())
print('Cleaning up')
s.deleteJobTemplate(jt)
os.remove(error_log)
if__name__=='__main__':
main()
results in
$ python foo.py
Creating job template
Your job has been submitted with ID 7990
Job: 7990 finished with status 2
/bin/sort: option requires an argument -- 't'
Try '/bin/sort --help' for more information.
Cleaning up
The text was updated successfully, but these errors were encountered:
stmlange
added a commit
to stmlange/slurm-drmaa
that referenced
this issue
Sep 10, 2019
Hello,
thank you for this library.
I noticed a small bug when using single quotes in arguments.
I believe that single quotes in the expanded args (
slurm-drmaa/slurm_drmaa/job.c
Line 615 in 665d5b5
In my case I'm running
which will then be translated into
However this fails with:
I believe what happens internally is that
bash -c
treatssource /tmp/init.sh ; /bin/sort
as the first string and as per documentation everything after becomes an argument:To solve this I believe that the single quotes within the expanded args should be escaped (e.g. via https://creativeandcritical.net/str-replace-c)
=======
consider this minimal example:
results in
The text was updated successfully, but these errors were encountered: