I'm still new to bash scripting, and I'm trying to get a script to work. The other scripts to which this refers, start.sh and stop.sh, work fine, as well as my references to them. The only problem is that running a bad option or no option at all, i.e., "multiseatctl.sh asdlkfjasdflkj" instead of "multiseatctl.sh start," just keeps looping with "Please enter one of the following parameters: 'start' 'stop' 'restart'" instead of assigning a new value to the variable and moving on. Can anyone help?
Code:
#!/bin/bash
# This script starts, stops, or restarts (stops-then-starts) the multiseat, RMI
# registry, Java, and the simulation. Ideally, the user will run it with
# "start," "stop," or "restart" as options. If not, he will be prompted to
# choose an option.
# Error tolerance.
while [ "$1" != "start" ] && [ "$1" != "stop" ] && [ "$1" != "restart" ]
do
echo 'Please enter one of the following parameters: "start" "stop" "restart"'
read newinput
$1=newinput
done
if [ "$1" = "start" ]; then
echo 'Starting the multiseat, RMI, and settings dialog box.'
# Call the start script.
/etc/X11/start.sh
# Add delays before providing text feedback, or it will be
# lost amongst other messages.
sleep 10
echo 'Ready to begin simulation.'
elif [ "$1" = "stop" ]; then
echo 'Stopping RMI and multiseat.'
# Call the stop script.
/etc/X11/stop.sh
sleep 10
echo 'RMI and multiseat stopped.'
else
echo 'Restarting RMI and the multiseat.'
# Stop
/etc/X11/stop.sh
# Start after a ten-second delay. Doing otherwise will try to
# start Java before the X servers have finished starting.
sleep 10
/etc/X11/start.sh
sleep 10
echo 'Ready to begin simulation.'
fi