Well for posterity sake here's what you can do if you can't write a CL command wrapper and want to use plink.exe to run IBMi programs or commands:
Original
plink -ssh "user@1.1.1.1<mailto:user@1.1.1.1>" -pw pass1 /bin/system 'CALL PGM(LIB/PGM) PARM("A99 " "B22 ")'
Fixed with special characters (,), / and ' escaped with a backslash \ and with double quotes around the entire command.
plink -ssh "user@1.1.1.1<mailto:user@1.1.1.1>" -pw pass1 /bin/system "CALL PGM\(LIB\/PGM\) PARM\(\'A99\' \'B22\'\)"
I favor the CL command wrapper though.
Almost as ugly as *TCAT and *BCAT in CL.
FYI: You can feedback CL commands via SNDPGMMSG if you plan to send back any CL responses from plink.exe
Regards,
/
[
http://static.helpsystems.com/hs/email/templates/signatures-final/images/hs-logo2.png]
Richard Schoen
Director of Document Management
e. richard.schoen@xxxxxxxxxxxxxxx<mailto:richard.schoen@xxxxxxxxxxxxxxx>
p. 952.486.6802
w. helpsystems.com<
http://www.helpsystems.com/>
[cid:image002.jpg@01D1A545.4C2BF250]<
http://www.linkedin.com/in/richardschoen>[cid:image003.jpg@01D1A545.4C2BF250]<
http://www.twitter.com/richardschoen>
From: Richard Schoen
Sent: Monday, January 22, 2018 11:53 AM
To: midrange-l@xxxxxxxxxxxx
Subject: Using plink to call system commands via SSH mangling parms
Hey All,
Interesting issue. Trying to use plink.exe to call CL commands from an SSH session in Windows.
Call works, but parm data mangled.
Example that does NOT convert char parms correctly: REM plink -ssh "user@1.1.1.1<mailto:user@1.1.1.1>" -pw pass1 /bin/system 'CALL PGM(LIB/PGM) PARM("999 " "222 ")'
Example that does convert char parms correctly with character prefix in each parm: REM plink -ssh "user@1.1.1.1<mailto:user@1.1.1.1>" -pw pass1 /bin/system 'CALL PGM(LIB/PGM) PARM("A99 " "B22 ")'
Apparently prefixing the character fields will cause the parm to convert to character. But if parm is numbers the parm gets turned numeric and thus the CL program interprets the parms as garbage.
I resolved the issue as usual by creating a CL command to front end the call to the CL program.
However is there a way to force the correct parm conversion using CALL/PARM instead ?
Thoughts appreciated.
PS: This is more for posterity as I'm sure others may run into this.
Regards,
[
http://static.helpsystems.com/hs/email/templates/signatures-final/images/hs-logo2.png]
Richard Schoen
Director of Document Management
e. richard.schoen@xxxxxxxxxxxxxxx<mailto:richard.schoen@xxxxxxxxxxxxxxx>
p. 952.486.6802
w. helpsystems.com<
http://www.helpsystems.com/>
[cid:image002.jpg@01D1A545.4C2BF250]<
http://www.linkedin.com/in/richardschoen>[cid:image003.jpg@01D1A545.4C2BF250]<
http://www.twitter.com/richardschoen>
As an Amazon Associate we earn from qualifying purchases.