How to Execute shell in more than one server?

Hi ,

I got a shell in one physical server and want to execute it in different servers. I did tried using ssh but iam not successful. Can someone through somelight on the subject and with some working examples ?

Also iam trying PHP in the front end to execute the shell and show the logs in the UI.
Not sure if this can be achieved through PHP as well.

FYI. Iam working on solaris boxes and got only readonly access to other servers.

Appreciate any help on it.

Regards,
Sukumar

Please show us what you have tried.

Hi,

Please find the below options which I have tried.

bsits001z$ ssh readonly@12.16.24.25  'exec bash' '/opt/tibco/logs/bw/EAI_Automation/test_automation.sh 447830748554'
Could not create directory '/home/readonly/.ssh'.
The authenticity of host '12.16.24.25 (12.16.24.25)' can't be established.
RSA key fingerprint is 4e:1d:f4:05:bb:d0:28:97:c3:1e:c9:32:0d:b9:1f:28.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/readonly/.ssh/known_hosts).
Password:
Could not chdir to home directory /home/readonly: No such file or directory
bash: /opt/tibco/logs/bw/EAI_Automation/test_automation.sh: No such file or directory
bsits001z$
bsits001z$ ssh readonly@12.16.24.25  'exec bash' < /opt/tibco/logs/bw/EAI_Automation/test_automation.sh 447830748554
Could not create directory '/home/readonly/.ssh'.
The authenticity of host '12.16.24.25 (12.16.24.25)' can't be established.
RSA key fingerprint is 4e:1d:f4:05:bb:d0:28:97:c3:1e:c9:32:0d:b9:1f:28.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/readonly/.ssh/known_hosts).
Password:
Could not chdir to home directory /home/readonly: No such file or directory
bash: 447830748554: No such file or directory

Hi All,

Appreciate your help.

regards,
cskumar.

Does /opt/tibco/logs/bw/EAI_Automation/test_automation.sh exist on the remote computer or the local one?

If it's on the local computer, you'll need to feed it into ssh. You can tell bash '-s' as in 'read from standard input and assume the following text are arguments', to pass in 447830748554 as $1.

ssh readonly@12.16.24.25  'exec bash -s 447830748554' < /opt/tibco/logs/bw/EAI_Automation/test_automation.sh

:slight_smile: Thanks..It worked perfectly

1 Like