Running commands on a remote Linux is not working

Viewed 27

I'm running a CentOS 7 and I want to execute commands on a remote server like that:

mclaw@ALHTACSS01 /home/mclaw> 
mclaw@ALHTACSS01 /home/mclaw> 
mclaw@ALHTACSS01 /home/mclaw> ssh -q hadoop1 "ndaf-cluster-status"
ksh: ndaf-cluster-status: not found
mclaw@ALHTACSS01 /home/mclaw> 
mclaw@ALHTACSS01 /home/mclaw> 

But if I login into the remote server and execute the command, it works:

mclaw@ALHTACSS01.default.masterclaw [mclaw] /home/mclaw> 
mclaw@ALHTACSS01.default.masterclaw [mclaw] /home/mclaw> ssh -q hadoop1
Last login: Tue Sep 13 14:33:20 2022 from 192.168.59.53
ULP 5.0.13 Platform for MC 8.0 (ISO version 5.0.13)
Setting up the MasterClaw environment...
mclaw@ALHTAHAD01.default.masterclaw [mclaw] /home/mclaw> 
mclaw@ALHTAHAD01.default.masterclaw [mclaw] /home/mclaw> ndaf-cluster-status
2022-09-13 14:43:36,945 INFO  [main] client.RMProxy (RMProxy.java:createRMProxy(98)) - Connecting to ResourceManager at ALHTAHAD01.default.masterclaw/192.168.79.172:8032
+-------------------------------+------------+-------+-------------------------+--------+-------+-------+
| Cluster                       | HDFS State | Nodes | HDFS Used / Total Space | Proc   | Disk% | Proc% |
+-------------------------------+------------+-------+-------------------------+--------+-------+-------+
| ALHTAHAD01.default.masterclaw | ONLINE     | 10    |   8.06 TB /  15.69 TB   | 61/142 |  51%  |  43%  |
+-------------------------------+------------+-------+-------------------------+--------+-------+-------+

+-------------------------------+------------+-------------------------+------+-------+-------+
| Node                          | YARN State | HDFS Used / Total Space | Proc | Disk% | Proc% |
+-------------------------------+------------+-------------------------+------+-------+-------+
| ALHTAHAD01.default.masterclaw | RUNNING    | 825.51 GB /   1.57 TB   | 8/13 |  51%  |  62%  |
| ALHTAHAD02.default.masterclaw | RUNNING    | 832.40 GB /   1.57 TB   | 5/15 |  52%  |  33%  |
| ALHTAHAD03.default.masterclaw | RUNNING    | 830.62 GB /   1.57 TB   | 9/15 |  52%  |  60%  |
| ALHTAHAD04.default.masterclaw | RUNNING    | 826.81 GB /   1.57 TB   | 7/15 |  51%  |  47%  |
| ALHTAHAD05.default.masterclaw | RUNNING    | 831.79 GB /   1.57 TB   | 6/15 |  52%  |  40%  |
| ALHTAHAD06.default.masterclaw | RUNNING    | 826.67 GB /   1.57 TB   | 6/15 |  51%  |  40%  |
| ALHTAHAD07.default.masterclaw | RUNNING    | 823.74 GB /   1.57 TB   | 8/13 |  51%  |  62%  |
| ALHTAHAD08.default.masterclaw | RUNNING    | 824.58 GB /   1.57 TB   | 5/13 |  51%  |  38%  |
| ALHTAHAD09.default.masterclaw | RUNNING    | 823.97 GB /   1.57 TB   | 3/13 |  51%  |  23%  |
| ALHTAHAD10.default.masterclaw | RUNNING    | 816.04 GB /   1.53 TB   | 4/15 |  52%  |  27%  |
+-------------------------------+------------+-------------------------+------+-------+-------+

+-------------+---------+--------------+-----------+------+
| Queue       | State   | Jobs W/R/C/F | Capacity  | Used |
+-------------+---------+--------------+-----------+------+
| ColdStore   | RUNNING | -            |   0%- 80% |   0% |
| DWH-Summary | RUNNING | -            |   0%- 70% |   0% |
| default     | RUNNING | -            |   5%- 25% |   0% |
| eoFB-query  | RUNNING | 0/0/9/0      |  15%- 80% |   0% |
| eoSearch    | RUNNING | -            |   0%- 50% |   0% |
| eoXdr       | RUNNING | -            |   0%-100% |   0% |
| ndaf-tools  | RUNNING | -            |   5%- 25% |   0% |
| eoFB-index  | RUNNING | 1/2/8327/0   |  15%-100% |   8% |
| DWH         | RUNNING | 0/3/1664/0   |  60%-100% |  36% |
+-------------+---------+--------------+-----------+------+

mclaw@ALHTAHAD01 [mclaw] /home/mclaw> 

I have tried to write the full path but still unsuccessful behavior:

mclaw@ALHTAHAD01 [mclaw] /home/mclaw> 
mclaw@ALHTAHAD01 [mclaw] /home/mclaw> ssh -q hadoop1 "/opt/anritsu/mclaw/bin/ndaf-cluster-status"
/opt/anritsu/mclaw/bin/ndaf-cluster-status[16]: q7java: not found [No such file or directory]
mclaw@ALHTAHAD01 [mclaw] /home/mclaw> 
1 Answers

The command you're trying to start apparently needs an environment setup that isn't completed unless you log in interactively. You could try these variants:

Excplicitly run your command through an interactive shell (I'm guessing at the path to your ksh here, you should check):

ssh -q hadoop1 /bin/ksh -i -c ndaf-cluster-status

Force allocation of a tty with -t:

ssh -qt hadoop1 ndaf-cluster-status

You can also combine the two, and you could try dropping -i, it may be enough to force it through a shell, without forcing it to be interactive. Or '-i' might not be enough, in which case you can try replacing -i with -l to make it a login shell. Which, if any, of the -i and -l options are needed depends on how your server is set up.

Edit: From the error message you posted in the comment, there seems to be progress! The "Setting up the MasterClaw environment" message means it't running the correct initialization file. I guess it really wants a tty (aka terminal) too, though, so try this:

ssh -qt hadoop1 /bin/ksh -l -c ndaf-cluster-status

(You shouldn't need both -i and -l, a login shell is always considered interactive, I think.)

If that still doesn't work, I'm out of ideas. You manage to start your program, but it tries to query the size of your terminal and fails. Debugging that requires knowledge of your program, and I have no idea what MasterClaw is.

Related