About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Troubleshooting
Problem
Running complex system commands can be a challenge over SSH, as pre-processing of the command can remove delimiters too soon.
An example might be:
ssh user@ibmisshhost ‘system “sbmjob cmd(call pgm(library/pgm) parm(‘9.0.0’ ‘S’ ‘ ‘)) job(jobname) jobq(jobq) hold(*yes)” ‘
The issue/challenge is getting the quotes delimited such that they don't get stripped off before the command parser/processor that they are intended for. In this flow, there are several parsers involved: the original shell where
the ssh command is entered, the ssh command itself, the shell on the sshd server side, the system command on the server
side, and finally the CL processor interpreting the sbmjob command
the ssh command is entered, the ssh command itself, the shell on the sshd server side, the system command on the server
side, and finally the CL processor interpreting the sbmjob command
What we see from debug output is that the actual system command being sent to the remote server is
debug1: Sending command: system "SBMJOB CMD(CALL PGM(STULIB/NULL) PARM(9.0.0 S )) JOB(TEST) HOLD(*YES)"
Resolving The Problem
To resolve the issue, it is necessary to use escape characters to prevent characters from being stripped and enclosing the whole statement in double quotes. Using the example above, the following should work:
ssh user@ibmisshhost "system \'sbmjob cmd(call pgm(library/pgm) parm(‘9.0.0’ ‘S’ ‘ ‘)) job(jobname) jobq(jobq) hold(*yes)\'”
Document Location
Worldwide
[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CKoAAM","label":"Communications-\u003ESFTP and SSH or Secure Shell"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]
Was this topic helpful?
Document Information
More support for:
IBM i
Component:
Communications->SFTP and SSH or Secure Shell
Software version:
All Versions
Operating system(s):
IBM i
Document number:
884702
Modified date:
03 June 2024
UID
ibm10884702
Manage My Notification Subscriptions