Skip to content

iCmd5250 doesn't work properly for CL commands with parameters #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kadler opened this issue Feb 21, 2020 · 0 comments · Fixed by #50
Closed

iCmd5250 doesn't work properly for CL commands with parameters #49

kadler opened this issue Feb 21, 2020 · 0 comments · Fixed by #50
Labels
bug Something isn't working
Milestone

Comments

@kadler
Copy link
Member

kadler commented Feb 21, 2020

@kadler after installing SI70667 PTF we are getting following error

sh: syntax error at line 1 : `(' unexpected
<?xml version="1.0" ?><xmlservice><sh error="on" var="aspgroup_cmd">
</sh>
</xmlservice>

Originally posted by @ranga543 in #48 (comment)

@kadler kadler added the bug Something isn't working label Feb 21, 2020
kadler added a commit that referenced this issue Feb 21, 2020
iCmd5250 is just a fancy wrapper around iSh, using the PASE system
command. It did not do any shell escaping/quoting, so it basically only
allowed calling CL commands without parameters or with only positional
parameters because the parentheses would cause the shell to gack.

eg.
iCmd5250('wrkactjob', 'WRKACTJOB SBS(QBATCH)')

basically became

iSh('wrkactjob', '/QOpenSys/usr/bin/system WRKACTJOB SBS(QBATCH)')

When executed, an error would be given from the shell:

sh: syntax error at line 1 : `(' unexpected

The proper fix is to quote the string, but that can be tricky to get
right. Luckily, Python has shlex.quote to do the hard work for us.
https://docs.python.org/3/library/shlex.html#shlex.quote

Fixes #49
kadler added a commit that referenced this issue Feb 22, 2020
iCmd5250 is just a fancy wrapper around iSh, using the PASE system
command. It did not do any shell escaping/quoting, so it basically only
allowed calling CL commands without parameters or with only positional
parameters because the parentheses would cause the shell to gack.

eg.
iCmd5250('wrkactjob', 'WRKACTJOB SBS(QBATCH)')

basically became

iSh('wrkactjob', '/QOpenSys/usr/bin/system WRKACTJOB SBS(QBATCH)')

When executed, an error would be given from the shell:

sh: syntax error at line 1 : `(' unexpected

The proper fix is to quote the string, but that can be tricky to get
right. Luckily, Python has shlex.quote to do the hard work for us.
https://docs.python.org/3/library/shlex.html#shlex.quote

Fixes #49
kadler added a commit that referenced this issue Apr 28, 2020
iCmd5250 is just a fancy wrapper around iSh, using the PASE system
command. It did not do any shell escaping/quoting, so it basically only
allowed calling CL commands without parameters or with only positional
parameters because the parentheses would cause the shell to gack.

eg.
iCmd5250('wrkactjob', 'WRKACTJOB SBS(QBATCH)')

basically became

iSh('wrkactjob', '/QOpenSys/usr/bin/system WRKACTJOB SBS(QBATCH)')

When executed, an error would be given from the shell:

sh: syntax error at line 1 : `(' unexpected

The proper fix is to quote the string, but that can be tricky to get
right. Luckily, Python has shlex.quote to do the hard work for us.
https://docs.python.org/3/library/shlex.html#shlex.quote

For Python 2, we have to add our own shlex.quote equivalent.

Fixes #49
@kadler kadler added this to the 1.7 milestone May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant