Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-02-2016, 09:48 AM   #16
LQ Newbie
Registered: Aug 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled

kindly find below result /usr/sbin/postqueue -p

[root@hostsvr /]# /usr/sbin/postqueue -p
Mail queue is empty
[root@hostsvr /]#
Old 09-02-2016, 09:50 AM   #17
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,370

Rep: Reputation: 387Reputation: 387Reputation: 387Reputation: 387

The problem is this command:

/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'
If you have postfix installed and mails in the queue, it will tell you the number of mails in the queue. But if the queue is empty, postqueue -p will simpy say "Mail queue is empty", and it will be filtered away by awk. I guess the person who wrote that script never had an empty mail queue

You can multiply with 1 in awk to always get a number (nothing multiplied by 1 is 0)

queuelength=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5 * 1}'`
Old 09-02-2016, 09:54 AM   #18
Registered: Oct 2015
Posts: 119

Rep: Reputation: 25
Well done Guttorm!
Old 09-02-2016, 09:58 AM   #19
LQ Newbie
Registered: Aug 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled

Thanks Guttorm the script will not work if the mailq is empty and I appreciate your effort and help gda

Thanks All


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
bash script error : integer expression expected linuxandtsm Linux - Newbie 7 01-07-2014 06:01 AM
[SOLVED] Error in Shell script if then - line 21: [: 0.38: integer expression expected Lucard Linux - Newbie 3 04-17-2013 11:42 AM
[: : integer expression expected if else condition Iyyappan Linux - Server 4 11-25-2012 02:09 AM
[SOLVED] if condition error: integer expression expected Kashif_Bash Programming 6 04-18-2012 05:37 AM
Error upgrading kernel, /sbin/mkinitrdi integer expression expected amp2000 Linux - General 2 12-05-2003 05:38 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:07 AM.

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