{"action":"created","issue":{"url":"https://api.github.com/repos/radical-cybertools/saga-python/issues/564","repository_url":"https://api.github.com/repos/radical-cybertools/saga-python","labels_url":"https://api.github.com/repos/radical-cybertools/saga-python/issues/564/labels{/name}","comments_url":"https://api.github.com/repos/radical-cybertools/saga-python/issues/564/comments","events_url":"https://api.github.com/repos/radical-cybertools/saga-python/issues/564/events","html_url":"https://github.com/radical-cybertools/saga-python/issues/564","id":163974603,"number":564,"title":"Improvements with method `_pbscript_generator()`","user":{"login":"wjlei1990","id":5777547,"avatar_url":"https://avatars.githubusercontent.com/u/5777547?v=3","gravatar_id":"","url":"https://api.github.com/users/wjlei1990","html_url":"https://github.com/wjlei1990","followers_url":"https://api.github.com/users/wjlei1990/followers","following_url":"https://api.github.com/users/wjlei1990/following{/other_user}","gists_url":"https://api.github.com/users/wjlei1990/gists{/gist_id}","starred_url":"https://api.github.com/users/wjlei1990/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wjlei1990/subscriptions","organizations_url":"https://api.github.com/users/wjlei1990/orgs","repos_url":"https://api.github.com/users/wjlei1990/repos","events_url":"https://api.github.com/users/wjlei1990/events{/privacy}","received_events_url":"https://api.github.com/users/wjlei1990/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-06T00:24:30Z","updated_at":"2016-07-06T03:01:00Z","closed_at":null,"body":"Hi,\r\n\r\nI found there is improvements could be made in `adaptors/pbs/pbsjob.py`. In the function of `_pbsscript_generator()`, line https://github.com/radical-cybertools/saga-python/blob/devel/src/saga/adaptors/pbs/pbsjob.py#L319:\r\n```python\r\n    # escape all double quotes and dollarsigns, otherwise 'echo |'\r\n    # further down won't work\r\n    # only escape '$' in args and exe. not in the params\r\n    exec_n_args = workdir_directives + exec_n_args\r\n    exec_n_args = exec_n_args.replace('$', '\\\\$')\r\n\r\n    pbscript = \"\\n#!/bin/bash \\n%s%s\" % (pbs_params, exec_n_args)\r\n    pbscript = pbscript.replace('\"', '\\\\\"')\r\n```\r\nThe replacement of `$` is not good if you want to put some bash variable inside your pbs script...but you can't do that because `$` will be translated to `\\$`.\r\n\r\nThe reason \"$\" needs to be replaced is because of line https://github.com/radical-cybertools/saga-python/blob/devel/src/saga/adaptors/pbs/pbsjob.py#L693:\r\n```python\r\n        cmdline = \"\"\"SCRIPTFILE=`mktemp -t SAGA-Python-PBSJobScript.XXXXXX` &&  echo \"%s\" > $SCRIPTFILE && %s $SCRIPTFILE && rm -f $SCRIPTFILE\"\"\" %  (script, self._commands['qsub']['path'])\r\n        ret, out, _ = self.shell.run_sync(cmdline)\r\n```\r\n\r\nHowever, this issue could solved if change the `echo \"%s\" > $SCRIPTFILE` to `echo '%s' > $SCRIPTFILE`. Thus, the echo just dump the string content in a verbose way without interpolation. Accordingly, the escape rule should be changed to:\r\n```python\r\n    # escape all single quotes, otherwise 'echo |'\r\n    # further down won't work\r\n    # only escape  in args and exe. not in the params\r\n    exec_n_args = workdir_directives + exec_n_args\r\n\r\n    pbscript = \"\\n#!/bin/bash \\n%s%s\" % (pbs_params, exec_n_args)\r\n    exec_n_args = exec_n_args.replace('\\'', '\\\\\\'')\r\n```\r\n\r\nI have created a pull request: https://github.com/radical-cybertools/saga-python/pull/566"},"comment":{"url":"https://api.github.com/repos/radical-cybertools/saga-python/issues/comments/230659787","html_url":"https://github.com/radical-cybertools/saga-python/issues/564#issuecomment-230659787","issue_url":"https://api.github.com/repos/radical-cybertools/saga-python/issues/564","id":230659787,"user":{"login":"wjlei1990","id":5777547,"avatar_url":"https://avatars.githubusercontent.com/u/5777547?v=3","gravatar_id":"","url":"https://api.github.com/users/wjlei1990","html_url":"https://github.com/wjlei1990","followers_url":"https://api.github.com/users/wjlei1990/followers","following_url":"https://api.github.com/users/wjlei1990/following{/other_user}","gists_url":"https://api.github.com/users/wjlei1990/gists{/gist_id}","starred_url":"https://api.github.com/users/wjlei1990/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wjlei1990/subscriptions","organizations_url":"https://api.github.com/users/wjlei1990/orgs","repos_url":"https://api.github.com/users/wjlei1990/repos","events_url":"https://api.github.com/users/wjlei1990/events{/privacy}","received_events_url":"https://api.github.com/users/wjlei1990/received_events","type":"User","site_admin":false},"created_at":"2016-07-06T03:01:00Z","updated_at":"2016-07-06T03:01:00Z","body":"However, at runtime, it gives some warnings like:\r\n```\r\n2016-07-05 22:56:19,735: radical.saga.cpi    : MainProcess                     : MainThread     : WARNING : flush: [    5] [    1] (discard data: '$')\r\n```\r\nHowever, the program still runs OK.\r\n\r\nAny clue?"}}
{"actor":{"display_login":"wjlei1990"}}