Reputation: 57
I am trying to send a command to the iSeries (AS/400) utilizing QCMDEXC from Python. I know I can connect to the iSeries because I can display members from QGPL:
src.execute('select * from qgpl/bwusrprf')
for row in src:
print (row)
I have tried all combinations of syntax for the "CALL QCMDEXC" (shown below) command with no success. Is this even possible? Is this the correct method to issue QCMDEXC?
Python code:
src.execute(call qcmdexc('dspusrprf usrprf(*all) output(*outfile) outfile(qgpl/audusrprf)', 0000000061.00000)
====================================================================================== Error message:
src.execute(call qcmdexc('dspusrprf usrprf(*all) output(*outfile) outfile(qgpl/audusrprf)', 0000000061.00000)
^
SyntaxError: invalid syntax
Upvotes: 1
Views: 1744
Reputation: 41148
You probably need quotes around the entire command as follows:
src.execute("call qcmdexc parm('dspusrprf usrprf(*all) output(*outfile) outfile(qgpl/audusrprf)', 0000000061.00000)")
or better yet declare it as a string:
parm = "dspusrprf usrprf(*all) output(*outfile) outfile(qgpl/audusrprf)"
cmd = "call qcmdexc parm('{0:s}', {1:016.5f})".format(parm, len(parm))
src.execute(cmd)
Upvotes: 3