I have a shell script as shown below:
#!/bin/bash
echo "Select the Gateway Server:"
echo " 1. Gateway 1"
echo " 2. Gateway 2"
echo " 3. Gateway 3"
read gatewayHost
case $gatewayHost in
1) gateway="abc.com" ;;
2) gateway="pqr.com" ;;
3) gateway="xyz.com" ;;
*) echo "Invalid choice" ;;
esac
/mypath/abc
In the above script, I select the gateway from user input and try to navigate to my abc.sh script, which is expected to be shown below:
set timeout 3
spawn ssh "james@$gateway"
expect "password:"
send "TSfdsHhtfs\r";
interact
But I can not pass the gateway variable from the shell script to expect a script. Can someone tell me how to achieve this? Please note that I need to use the shell script only for outdated reasons (cannot use tcl script or cannot do everything while waiting for the script)
source
share