IBM Support

Using the secure shell (ssh) Utility to Run CL Commands Remotely Through an SSH
Connection

Troubleshooting


Problem

The document describes how to run CL commands remotely through an SSH connection.

Resolving The Problem

The SSH utility has several switches and parameters that allow you to run a shell command remotely
without first entering the remote shell. The following examples show you a couple of different ways to use this function:

  • The following command establishes an SSH session under user profile BARLEN2 to the i5OSP2 system and submits a backup job in i5/OS:

ssh -T barlen2@i5osp2 'system "SBMJOB CMD(CALL PGM(TOOLS/BACKUPLIBS) PARM(*ALL)) JOB(BACKUP)" '

As a result of this command, the shell displays the following i5/OS message that was issued on the remote system:

CPC1221:  Job 015242/BARLEN2/BACKUP submitted to job queue QBATCH in library QGPL.

The system command is used in the i5/OS PASE shell to run i5/OS commands.
  • In this example, the Display Message (DSPMSG) command for displaying the QSYSOPR message queue is run:

ssh -T barlen@i5osps2 'system "DSPMSG QSYSOPR" '

As opposed to the first example where you received the message about the submission of the job, the DSPMSG command returns the
output to the source system's i5/OS PASE shell.

    CPC9802: Printer output created.
    5722SS1 V5R3M0 040258 Messages in queue - QSYSOPR
    Page 0001
    MSGID SEV MSG TYPE
    CPI1E23 00 COMPLETION Cleanup has started.
    QSYSSCD QPGMR 012895 QEZEVTHL 0000 01/05/06 23:00:21.246696 QPGMR
    CPI1E88 00 INFO Cleanup of OfficeVision/400 calendar items started.
    QCLNCALITM QPGMR 014930 QEZCLOFC 0000 01/05/06 23:00:21.273736 QPGMR

Note: These two examples always require you to enter a password when connecting to the remote system. In many cases, this is not desirable because some commands should be run in unattended or batch mode. Automatic sign-on can be achieved with SSH by using public key authentication.

[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Communications-TCP","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Historical Number

538530884

Document Information

Modified date:
18 December 2019

UID

nas8N1012704