//View Tip #365
Similar Tips
There are no more tips with these tags. Perhaps you'd like to submit one, or browse the archives.


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
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

View Comments »


Add your comment

Comments are currently disabled
If you don't want to use a new file getting SERVER and PORT, you can use:

PORT=$(DISPLAY=:0 dialog --inputbox "Enter the port on the SCS device that you want to connect to" 10 60)

shell-fu rocks!
Posted 2008-09-27 03:42:19

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit