suhas savkoor
suhas savkoor

Reputation: 133

Exit from SSH using a sh script

I have a RHEL box (bash) and I have SSH'd to an ESXi (sh) from it.

Now on ESXi I have created a simple script

#!/bin/sh
echo hello
exit

This only exits the script. I want to exit the script + exit the ESXi shell and return to my original RHEL bash.

Thanks much.

Upvotes: 1

Views: 631

Answers (2)

MerrillFraz
MerrillFraz

Reputation: 79

If you are only SSHing in for the purpose of running this command, then instead you could just have the ssh run the command for you:

[RHEL]$ ssh user@ESXi '/tmp/myscript.sh'

...and if you needed to interact with the script, or watch it's output, add the -t switch:

[RHEL]$ ssh -t user@ESXi '/tmp/mysctipt.sh'

Upvotes: 1

sjsam
sjsam

Reputation: 21965

Remove the shebang ie do

echo hello && exit

save it as script and then source the script like

. script 

Upvotes: 0

Related Questions