The syntax of certain commands that are executed remotely in the CTPOS Command Line Interface have changed for CTPOS 9.0R1 and later releases. This article provides examples of the new syntax changes.
In earlier CTPOS releases such as 7.x, it has been possible to use SSH to run remote commands by using the " cmd " argument.
cmd
For instance, to check the CTPOS version:
% ssh [email protected] cmd -v CTPOS CLI version: 7.3R7 201101 Compile Time: Sun Nov 01 2020 06:17:03 PM Flash: Single Image
Or to query or edit a bundle:
% ssh [email protected] cmd bndl 0 qry state db DBase State: ACTIVE % ssh [email protected] cmd bndl 0 disable % ssh [email protected] cmd bndl 0 qry state db DBase State: DISABLED % ssh [email protected] cmd bndl 0 activate % ssh [email protected] cmd bndl 0 qry state db DBase State: ACTIVE %
Many users have taken advantage of this ability to build scripts to manage CTPs.
Starting with CTPOS release 9.0R1, and continuing forward, the default shell for CTPOS is bash (instead of tcsh that was used previously). For many, this switch in shells will be transparent.
But for remote commands, there are some significant differences in behavior. Unlike tcsh, bash does not load the user environment during non-interactive invocation, which is what is done for remote execution. As a result, among other things:
The ctp_cmd user cannot run bundle modification operations
ctp_cmd
Aliases are not loaded
However, for each of these situations, there is a workaround.
For bundle modification operations, you can see that the above commands no longer work:
% ssh [email protected] cmd bndl 0 qry state db DBase State: ACTIVE % ssh [email protected] cmd -v CTPOS CLI version: 9.1R2 201202 Compile Time: Wed Dec 02 2020 03:44:56 PM SSH_SSL Version Changed: sh: /usr/bin/ssh: Permission % ssh [email protected] cmd bndl 0 qry state db DBase State: ACTIVE % ssh [email protected] cmd bndl 0 disable >>> ******************************************************* >>> *** This user does not have privileges to do this >>> ******************************************************* % ssh [email protected] cmd bndl 0 qry state db DBase State: ACTIVE %
But by including sudo before cmd , these commands will still work:
sudo
% ssh [email protected] sudo cmd bndl 0 qry state db DBase State: ACTIVE % ssh [email protected] sudo cmd bndl 0 disable % ssh [email protected] sudo cmd bndl 0 qry state db DBase State: DISABLED % ssh [email protected] sudo cmd bndl 0 activate % ssh [email protected] sudo cmd bndl 0 qry state db DBase State: ACTIVE %
And when running aliases remotely, they can be called directly in CTPOS 7.x:
% ssh [email protected] sb >>>>> Circuit Emulation Bundles <<<<< Bndl BndlTyp Port TS RemAddr CID LCID RunState RCtr ========================================================================== 0 CTP se-0/0 N/A 172.25.62.50 0 0 RUNNING 1 1 CTP se-0/1 N/A 172.25.62.50 1 1 RUNNING 0 2 CTP se-0/2 N/A 172.25.62.50 2 2 RUNNING 0 3 CTP se-0/3 N/A 172.25.62.50 3 3 RUNNING 0 4 CTP te-1/0 N/A 172.25.62.50 4 4 RUNNING 0 5 CTP te-1/1 N/A 172.25.62.50 5 5 RUNNING 0 6 CTP te-1/2 N/A 172.25.62.50 6 6 RUNNING 0 7 CTP te-1/3 N/A 172.25.62.50 7 7 RUNNING 0 ========================================================================== Checked out PPS - All Bundles: 1504, System Maximum: 12500 (1 PPS = full duplex packet transfer, Bundle <---> IP network) %
Whereas the same will not run in CTPOS 9.x:
% ssh [email protected] sb >>> sb: need at least one file to send >>> Try `sb --help' for more information.
In this case, it is necessary to tell bash to load the environment before attempting to execute an alias:
% ssh [email protected] -t 'bash -ic "sb" ' >>>>> Circuit Emulation Bundles <<<<< Bndl BndlTyp Port TS RemAddr CID LCID RunState RCtr ========================================================================== 0 CTP te-0/0 N/A 172.25.62.31 0 0 RUNNING 1 1 CTP te-0/1 N/A 172.25.62.31 1 1 RUNNING 0 2 CTP te-0/2 N/A 172.25.62.31 2 2 RUNNING 0 3 CTP te-0/3 N/A 172.25.62.31 3 3 RUNNING 0 4 CTP se-1/0 N/A 172.25.62.31 4 4 RUNNING 0 5 CTP se-1/1 N/A 172.25.62.31 5 5 RUNNING 0 6 CTP se-1/2 N/A 172.25.62.31 6 6 RUNNING 0 7 CTP se-1/3 N/A 172.25.62.31 7 7 RUNNING 0 ========================================================================== Checked out PPS - All Bundles: 1504, System Maximum: 12500 (1 PPS = full duplex packet transfer, Bundle <---> IP network) Connection to 172.25.62.31 closed. %
Note that a " -t " option is used for SSH, and it explicitly invokes a bash shell with " -ic " options. This same syntax can be used to run other commands that may not run otherwise with the simple SSH syntax.
-t
-ic