I have a script that asks for input from the user. When I run this locally it does what I want however I'd really like to run it over ssh.
I've tried the regular ways I'd run a script:
ssh someaccount@somemachine 'mysscript.sh'
ssh someaccount@somemachine 'bash -s' < myscript.sh'
but when it runs it does not wait for any user input and doesn't allow you to chose from the menu.
#!/bin/bash
# Bash Menu Script Example
echo -n "What machine is sick ?"
read machine
PS3='Please enter your choice: '
options=("Ping $machine" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Ping $machine")
echo "you chose to ping $machine"
ping -c1 $machine
;;
"Option 2")
echo "you chose choice 2"
;;
"Option 3")
echo "you chose choice 3"
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
Thanks
select
takes numbered options. – mikeserv Feb 20 '15 at 04:18