onesixnine
03-11-2004, 07:32 PM
Ok, today I decided to try my hand at some shell scripting. I have been using linux for close to 4 years now but have never wrote any of my own scripts ...
Anyways, I decided to write a script that would start and stop my UT2003 server. I initially put the UT server startup string in another small script, (called startupUT) which this main script calls on.
The whole things works pretty flawlessly, you enter a 1-3 and it performs the options it is supposed to.
But, when you just press enter, I thought I had made it so it would just say "you must enter a number between [1-3], and it does that, but it also prints some other output for some reason. It prints this:
/usr/bin/manageut: line 10: test: -eq: unary operator expected
/usr/bin/manageut: line 14: test: -eq: unary operator expected
/usr/bin/manageut: line 18: test: -eq: unary operator expected
you must enter a number between [1-3]
Here is my script:
clear
input=0
echo "UT Server Manager"
echo "1. Start UT Server"
echo "2. Don't start : exit"
echo "3. Stop UT Server"
echo -n "Enter in your choice [1-3]"
read input
if test $input -eq 1
then
echo "starting UT Server"
startupUT
elif test $input -eq 2
then
echo "Ok, closing now"
exit 1
elif test $input -eq 3
then
echo "Shutting down UT server now!"
killall -e ucc-bin
else
echo "you must enter a number between [1-3]"
fi
Any help/comments/opinions/flames ???
thanks :)
Anyways, I decided to write a script that would start and stop my UT2003 server. I initially put the UT server startup string in another small script, (called startupUT) which this main script calls on.
The whole things works pretty flawlessly, you enter a 1-3 and it performs the options it is supposed to.
But, when you just press enter, I thought I had made it so it would just say "you must enter a number between [1-3], and it does that, but it also prints some other output for some reason. It prints this:
/usr/bin/manageut: line 10: test: -eq: unary operator expected
/usr/bin/manageut: line 14: test: -eq: unary operator expected
/usr/bin/manageut: line 18: test: -eq: unary operator expected
you must enter a number between [1-3]
Here is my script:
clear
input=0
echo "UT Server Manager"
echo "1. Start UT Server"
echo "2. Don't start : exit"
echo "3. Stop UT Server"
echo -n "Enter in your choice [1-3]"
read input
if test $input -eq 1
then
echo "starting UT Server"
startupUT
elif test $input -eq 2
then
echo "Ok, closing now"
exit 1
elif test $input -eq 3
then
echo "Shutting down UT server now!"
killall -e ucc-bin
else
echo "you must enter a number between [1-3]"
fi
Any help/comments/opinions/flames ???
thanks :)