running bash script remotely and do some interaction between server and local

时间:2015-07-28 22:28:18

标签: bash

I have a script in my local:

rsh $server /usr/path/scriptB

So basically it just runs "scriptB" on remote server.

On server, I have "scriptB"

echo "1. Walk"
echo "2. Run"
echo "3. Exit"

read -p "Please enter option and press RETURN: " option
case $option in
  1) 
     echo "Selected Walk"
     read -p "Please enter your name: " name
     echo $name
     ;;
  2)
     ...
esac

I created a simple menu in scriptB and ask user to type option (1-3), if user enters 1 then ask user to enter his name and print it out.

After running this script, it can display the original menu properly

1. Walk
2. Run
3. Exit

However it doesn't show the line

Please enter option and press RETURN: 

but I am able to type the option. After entering "1" the program shows

Selected Walk

then it hangs and never goes further, whatever I type in the prompt. I have to kill it each time.

Does anyone know where the problem is? How to fix my script on both local and remote server? Thank you

0 个答案:

没有答案