shell script to run after ssh logout from another machine

Scenario:
I currently manager a cluster at work which is on a private network and i constantly need to ssh to other clients for diags e.t.c. I created a debain client which i use as my gateway to get to all the clients on the private network and I then created a Shell menu script which will make it easier for me to access all the clients, get diags...e.t.c

I have managed to get the script to work (by putting it in the .bashrc) to run every time the "test" user logs in which is good. I use this machine to ssh to other machines too...

so my problem:
Is it possible to have this script run when i exit a ssh session from another client back into this debian machine? i.e

client a = my machine
client b = gateway machine to private network with menu script
client c,d,e = private network clients

client a will ssh to client b (as test) - menu loads. I select option 1 to ssh to client c, do some stuff and exit client c back to client b. This currently gets me to a bash prompt - I want this to load the menu again so i can easily do other things rather than manually loading the menu again. (hope that makes sense)

is that possible?

Please, show us your script code from .bashrc

Jean-Pierre.

This is the menu i'm using:

.bashrc

./login.sh
#!/bin/bash

clear # Clear the screen.

echo "          SSH to a client"
echo "          ------- ----"
echo "Choose one of the following clients:"
echo
echo "[1] management"
echo "[2] Node1 "
echo "[q] Quit  "
echo

read client

case "$client" in
"1" )
echo
echo "You have chosen to ssh to management - Wait..."
echo
ssh user@<ipaddress>
;;

"2" )
echo
echo "You have chosen to ssh to Node1 - Wait..."
echo
ssh user@<ipaddress>
;;

"Q" | "q" )
echo
echo "Exiting to console prompt - Wait..."
echo
exit 0
;;

* )
echo
echo "Invalid option selected - exiting to console...."
echo
;;

esac

exit 0
         

Something like that ?

#!/bin/bash

clear # Clear the screen.

while :
do

echo "          SSH to a client"
echo "          ------- ----"
echo "Choose one of the following clients:"
echo
echo "[1] management"
echo "[2] Node1 "
echo "[q] Quit  "
echo

read client

case "$client" in
"1" )
echo
echo "You have chosen to ssh to management - Wait..."
echo
ssh user@<ipaddress>
;;

"2" )
echo
echo "You have chosen to ssh to Node1 - Wait..."
echo
ssh user@<ipaddress>
;;

"Q" | "q" )
echo
echo "Exiting to console prompt - Wait..."
echo
break
;;

* )
echo
echo "Invalid option selected - exiting to console...."
echo
;;

esac

done
exit 0

Jean-Pierre.

perfect that worked great! thank you!