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
Post a Comment