linux - Command to disconnect SSH connection from Script -


i have script:

#!/bin/bash #!/usr/bin/expect dialog --menu "please choose server connect to:" 10 30 15 1 ras01 2>temp  #ok pressed if [ "$?" = "0" ]         _return=$(cat temp)          # /home selected         if [ "$_return" = "1" ]                         dialog --infobox "connecting server ..." 5 30  ; sleep 2                 telnet xxx         fi  # cancel pressed else         exit fi  # remove temp file rm -f temp 

in part of code says: # cancel pressed want insert type of command disconnect session , close terminal automatically. ive tried different variations of exit, exit 1, exit 5, close, etc. none seem trick

here can do:

kill -9 "$(ps --pid $$ -oppid=)" 

but suggest not use way. better solution exit code of script , exit if needed. example

yourscript:

#... ... else     exit 1 fi 

and in ssh connection do:

./myscript || exit 

this correct way. try use it


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

tags - Jquery Mixitup plugin help prevent handlers being destroyed -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -