The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 08-30-2007
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
pipe may not be working

I am not sure what exactly is the reason, but the o/p of postsuper -d seems to be not piped to tail command. Try this,
Redirect the o/p of postsuper -d to some tempfile. Get the count of messages from the tempfile.
Code:
mailq | grep -v "^[^0-9A-Z]+" | grep MAILER-DAEMON | awk '{print $1}' | postsuper -d - >tempfile
no_of_msgs=$(tail -1 tmpfile |awk '{print $3}')
The rest being the same. Remove the tempfile afer the work is over. If this is not working, then do check if the last line is a blank line in the tempfile. Empty lines at the end could also distort the o/p. But I donot know how postsuper works to clearly identify the cause. Hope that helps!!