2008-07-17, 05:09 PM
Howdy,
I am writing a shell script for users with no knowledge of UNIX. The script will be used as their shell and will give them options on things to do/execute. I need to allow them to telnet, ssh, etc. to devices. The following is what i have so far:
Code:
#!/bin/sh
#set -x
user=`whoami`;
CLEAR=`which clear`;
TELNET=`which telnet`;
MENU=/usr/local/query/menu;
SSH=`which ssh`;
_Menu ()
{
$CLEAR;
echo " "
echo " ============================================================"
echo " NS2 MENU "
echo " ============================================================"
echo " 1. Telnet to a Device 12. CMTS Intfc Modem Count"
echo " 2. SSH to a Device 13. Ping/Traceroute Device"
echo " 3. Clear SSH Known Hosts 14. "
echo " 4. Access Core1 GSR 15. "
echo " 5. Access Core2 GSR 16. "
echo " 6. Access Core3 VXR 17. "
echo " 7. 18. "
echo " 8. 19. "
echo " 9. 20. "
echo " 10. 21. "
echo " 11. Access Server 22. "
echo " ============================================================"
echo " Select a Menu Number Option "or" "
echo " Type H# for Help on a Menu Option "or" "
echo " --Q to Quit Menu-- "
echo " ============================================================"
echo -n "Enter Menu Option ======> "
read option;
case "$option" in
1)
_telnet;
;;
2)
_ssh;
;;
3)
_clearssh;
;;
4)
_core1;
;;
5)
_core2;
;;
6)
_core3;
;;
11)
_aov;
;;
12)
_mdmcnt;
;;
13)
_pingtrace;
;;
*)
$CLEAR;
echo -e "You chose an invalid response. Please try again.\n Press any key to continue.";
read junk;
$MENU
;;
esac
}
_telnet ()
{
$CLEAR;
echo -n "Enter IP address of device and press Return: ";
read host;
$TELNET $host;
}
_ssh ()
{
$CLEAR;
echo -n "Enter IP address of deivce and press return: ";
read host;
$SSH $host
}
_clearssh ()
{
$CLEAR;
echo -e "Know hosts has been cleared.\n Press any key to continue.";
read junk;
$MENU;
}
_core1 ()
{
$CLEAR
$TELNET <someIP>
}
_core2 ()
{
$CLEAR
$TELNET <someIP>
}
_core3 ()
{
$CLEAR
$TELNET <someIP>
}
_aov ()
{
$CLEAR
$SSH 216.54.59.140
}
_Menu
The problem i am having is that after remoting into another box, i lose the shell script as the shell when they come back. If anyone has any suggestions, i am all ears (znx).