LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-01-2011, 07:42 PM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431
Blog Entries: 35

Rep: Reputation: 3
/mnt/sda1/blogrss_chroot.sh: line 2: [: ==: unary operator expected


My script is:
Code:
PID=$(pidof lighttpd)
if [ "$PID" == "" ] ; then
/etc/init.d/lighttpd start
fi
CONF="/etc/lighttpd/lighttpd.conf"
IP=$(ifconfig eth0 | grep "inet" | tr -s ' ' | sed 's/:/ /g' | cut -d ' ' -f 4)
while read line
do
if `echo $line | grep "server.port" 1>/dev/null 2>&1` ; then
SPORT=$(echo "$line" | cut -d'=' -f2)
SPORT=$(echo "$SPORT" | sed 's/ //g')
fi
done < $CONF

wget $IP:$SPORT/blog/rssfeed.php
if [ "$PID" == "" ] ; then
/etc/init.d/lighttpd stop
fi
echo "Blog: Updated at "`date "+%m/%d/%Y %H:%M:%S"`
/mnt/sda1/blogrss_chroot.sh: line 2: [: ==: unary operator expected
Can anyone explain the error?
thanks,
 
Old 04-01-2011, 09:45 PM   #2
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 386

Rep: Reputation: 43
Have you tried using the -z test operator to check for NULL?

Code:
if [ -z "$PID" ]; then
  /etc/init.d/lighttpd start
fi
Just a thought...
 
Old 04-02-2011, 12:51 AM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431

Original Poster
Blog Entries: 35

Rep: Reputation: 3
thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: unary operator expected ?? Lynda_M Programming 3 11-29-2008 08:03 PM
unary operator expected error! Lynda_M Programming 3 11-29-2008 12:04 PM
unary operator expected MONKEYJUDO Linux - Newbie 1 07-13-2008 06:05 AM
Unary Operator expected. Bash script Blackout_08 Programming 2 06-22-2006 02:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration