May 01, 2024, 10:00:13 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: unary operator expected error?  (Read 5946 times)

Offline Lynda_M

  • New Member
  • Posts: 1
unary operator expected error?
« on: November 29, 2008, 09:00:36 AM »
Hi everyone,
I'm a Linux newbie and would appreciate any help solving my issue...
I'm running a script to set up Linux OS environment, the script works great but i get an error on the following portion:

if [ $USERNAME != "root" ]
then
echo "Cannot proceed with setup.You must be logged in as root!"
exit
else
proc=m
while [ $proc != "y" -a $proc != "Y" -a $proc != "n" -a $proc != "N" ]
do
echo -n "Are you ready to proceed?(Y/N)"
read proc
if [ $proc == "n" -o $proc == "N" ]
then
exit
else
if [ $proc == "y" -o $proc == "Y" ]
then
continue
fi
fi
done
fi

The error i get:
line:2 [: !=: unary operator expected.
But the script continues to run...
Any help eliminating that error please!
Thanks in advance.

Offline debasish.raychawdhuri

  • New Member
  • Posts: 3
Re: unary operator expected error?
« Reply #1 on: January 04, 2009, 06:17:50 AM »
you should use $USER instead of $USERNAME