LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-07-2015, 11:38 AM   #1
Mackhand
LQ Newbie
 
Registered: Aug 2014
Posts: 6

Rep: Reputation: Disabled
Postfix throwing error /etc/init.d/postfix: line 73: [: =: unary operator expected


when I start postfix I get this error although it does start it is not sending mail

here is line 73
/etc/init.d/postfix: line 73: [: =: unary operator expected

here is the whole section
start() {
[ "$EUID" != "0" ] && exit 4
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
conf_check
# Start daemons.
echo -n $"Starting postfix: "
make_aliasesdb >/dev/null 2>&1
[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE
/usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
echo
return $RETVAL
}


I have another setup with the same exact code and it is working fine...
 
Old 01-07-2015, 11:46 AM   #2
sudowtf
Member
 
Registered: Nov 2013
Posts: 205

Rep: Reputation: 46
check running via bash vs sh maybe. i've had that issue (with custom scripts) in the past.

edit:
try doublequotes around "${NETWORKING}"
-or-
use [[ and ]] around expression

http://www.shellcheck.net

Last edited by sudowtf; 01-07-2015 at 01:46 PM.
 
1 members found this post helpful.
Old 01-07-2015, 01:28 PM   #3
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Rep: Reputation: 220Reputation: 220Reputation: 220
Can you show which line is line 73 exactly?
 
Old 01-07-2015, 01:53 PM   #4
Mackhand
LQ Newbie
 
Registered: Aug 2014
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sudowtf View Post
check running via bash vs sh maybe. i've had that issue (with custom scripts) in the past.

edit:
try doublequotes around "${NETWORKING}"
-or-
use [[ and ]] around expression

http://www.shellcheck.net
Thanks!
Looks like postfix not sending is unrelated to this error. I set selinux to permissive and restarted postfix still got the error but relay is working as expected. I also ran bash -x postfix but I don't understand the output looks like it just printed the settings. I'll try the double [ I saw that mentioned somewhere else but didn't really explain what that does.
 
Old 01-07-2015, 02:00 PM   #5
Mackhand
LQ Newbie
 
Registered: Aug 2014
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by average_user View Post
Can you show which line is line 73 exactly?
Sorry I meant to put that in OP it is

[ -x $CHROOT_UPDATE ] && $CHROOT_UPDATE


I changed [ ${NETWORKING} = "no" ] && exit 1 to [ "${NETWORKING}" = "no" ] && exit 1 as sudowtf mentioned and that fixed it.
 
Old 01-07-2015, 02:05 PM   #6
sudowtf
Member
 
Registered: Nov 2013
Posts: 205

Rep: Reputation: 46
The solution came from this link and also explains why: https://stackoverflow.com/questions/...rator-expected

Use that shellcheck site, it saved me tons of times.
 
Old 03-14-2015, 12:55 PM   #7
Rob R.
LQ Newbie
 
Registered: Mar 2015
Posts: 1

Rep: Reputation: Disabled
Thanks, this worked for me on CentOS

Thanks, changing line 73 to be:

Code:
[ "${NETWORKING}" = "no" ] && exit 1

and then:

Code:
# service postfix restart

did it for me on CentOS


Code:
# cat /etc/centos-release
CentOS release 6.5 (Final)
Code:
# uname -r
2.6.32-431.5.1.el6.x86_64
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unary operator expected error greenpool Linux - Newbie 1 01-31-2012 07:36 PM
[SOLVED] /mnt/sda1/blogrss_chroot.sh: line 2: [: ==: unary operator expected ted_chou12 Programming 2 04-02-2011 12:51 AM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:57 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