IBM Support

Running remote system commands on an IBM i SSH Server may fail due to pre-processing of commands

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

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"}]

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