1

Tip #365   Ask questions, get answers, do something...

This a dialog script that asks the user a couple of questions and then does something with the answers.

It was something quick and dirty to accomplish a task I needed.

# This piece asks a question and stores the answer in a buffer file.
dialog --inputbox "Enter the hostname or IP of the SCS device you want to connect to..." 10 60 2>/home/SCS/out/server

# This was another piece of information that I needed to accomplish the task I needed.
dialog --inputbox "Enter the port on the SCS device that you want to connect to" 10 60 2>/home/SCS/out/port

# Here is where i set my variables with the buffer files from above.
SERVER=`cat /home/SCS/out/server`
PORT=`cat /home/SCS/out/port`

# This was just a piece to help me make sure my variable were set right.
# I often write in escape route in my scripts so that i can test them without blowing stuff up.
echo "You will now be transported to $SERVER on port $PORT."

# Here I give myself 5 seconds to ctrl +c the script.
sleep 5

#and finally the action to take with the answers from above.
ssh $SERVER -t -t connect $PORT