Sponsored Content
Top Forums Shell Programming and Scripting capturing line from script output and appending to a file Post 302134335 by ranj@chn on Thursday 30th of August 2007 10:29:12 AM
Old 08-30-2007
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!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

capturing output in script

I have the following line in my script: $sftpcmd $rmthost <<COMMANDS>> $sftplog 2>&1 For some reason this is not capturing the errors from sftp, they go to the file attached to the cron entry ie mm hh dd MM * /myscript > cron.out any idea why? digital unix 4.0d (6 Replies)
Discussion started by: MizzGail
6 Replies

2. Shell Programming and Scripting

Capturing shell script command output

I am trying to check to see if a file exists on a ftp server, well, I know that cant be done, atleast directly, So I came up with this small script ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD cd public_html/crap dir $FILE quit END_SCRIPT Where the $ variable... (2 Replies)
Discussion started by: designflaw
2 Replies

3. Shell Programming and Scripting

Capturing Sybase SP output in Shell Script

Greetings, I need to capture the output of a Sybase stored procedure, inside my shell script( k shell). Based on this output, I need to call another perl script, with input arguments as the result set of the procedure execution. I need to keep looping through and call the perl script, ... (2 Replies)
Discussion started by: rajpreetsidhu
2 Replies

4. Shell Programming and Scripting

Problem capturing output in TCL script

I have a TCL script that logs into a switch using expect.I send a command "show port-security address" and it returns a table having a large number of rows.I need to capture this output(the table) and store it in a .txt file. I have done this: match_max 5000 set expect_out(buffer) {} set... (0 Replies)
Discussion started by: plasmalightwave
0 Replies

5. Shell Programming and Scripting

Capturing output of procedure in variable in shell script

Hi guys I am calling one DB2 stored proc through unix. It is giving me below output. I want to capture the value 150 in one UNIX variable in shell script. Please let me know how I can achieve this. Thanks in advance Value of output parameters -------------------------- Parameter Name :... (5 Replies)
Discussion started by: vnimavat
5 Replies

6. Shell Programming and Scripting

Appending script output to file

Hi guys, I have a script from which I would like its standard output results (upon execution) to be appended to a separate file (.txt format). How can I write such a command into the script for this to occur? I know there should be a >> involved somewhere. Thanks! (5 Replies)
Discussion started by: jjb1989
5 Replies

7. Shell Programming and Scripting

Capturing script output and input to log

Hi Is there a way that I can capture a shell script (both output and input) to a log file where I can analyze it? Thanks (6 Replies)
Discussion started by: nimo
6 Replies

8. Shell Programming and Scripting

Appending standard C Time on each line out output

I have a command : nawk 'BEGIN{print srand()}' which gives the amount of seconds between January 1st 1970 00:00:00 (Unix Epoch) and the present time, to the closest second and I would want to append this time stamp every minute in a file which contains the data below which also has one row... (1 Reply)
Discussion started by: thinktank
1 Replies

9. Shell Programming and Scripting

Help capturing output of expect script

match_max 500000 set timeout 30 set outcome1 {} set outcome2 {} set inputfile C:\\Users\\Administrator\\Desktop\\inputfile.txt send -i $con "\r"; expect -i $con "Desktop>" { exp_send "type $inputfile \r" } set timeout 30 expect { "Desktop>" { set outcome $expect_out(0,string);}... (3 Replies)
Discussion started by: cityprince143
3 Replies

10. Shell Programming and Scripting

Appending output to file

Hi, I want to calculate std dev for a list of files and then print the output appended to an existing file. I have a few folders within the directory Folder, and I am interested in getting the std dev of values in files named as time.txt. In the last pipe, if I print just the sd value, it... (1 Reply)
Discussion started by: jamie_123
1 Replies
POSTSUPER(1)						      General Commands Manual						      POSTSUPER(1)

NAME
postsuper - Postfix superintendent SYNOPSIS
postsuper [-psv] [-c config_dir] [-d queue_id] [-h queue_id] [-H queue_id] [-r queue_id] [directory ...] DESCRIPTION
The postsuper(1) command does maintenance jobs on the Postfix queue. Use of the command is restricted to the superuser. See the postqueue(1) command for unprivileged queue operations such as listing or flushing the mail queue. By default, postsuper(1) performs the operations requested with the -s and -p command-line options on all Postfix queue directories - this includes the incoming, active and deferred directories with mail files and the bounce, defer, trace and flush directories with log files. Options: -c config_dir The main.cf configuration file is in the named directory instead of the default configuration directory. See also the MAIL_CONFIG environment setting below. -d queue_id Delete one message with the named queue ID from the named mail queue(s) (default: hold, incoming, active and deferred). If a queue_id of - is specified, the program reads queue IDs from standard input. For example, to delete all mail with exactly one recipient user@example.com: mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($8 == "user@example.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d - Specify "-d ALL" to remove all messages; for example, specify "-d ALL deferred" to delete all mail in the deferred queue. As a safety measure, the word ALL must be specified in upper case. Warning: Postfix queue IDs are reused. There is a very small possibility that postsuper deletes the wrong message file when it is executed while the Postfix mail system is delivering mail. The scenario is as follows: 1) The Postfix queue manager deletes the message that postsuper(1) is asked to delete, because Postfix is finished with the mes- sage (it is delivered, or it is returned to the sender). 2) New mail arrives, and the new message is given the same queue ID as the message that postsuper(1) is supposed to delete. The probability for reusing a deleted queue ID is about 1 in 2**15 (the number of different microsecond values that the system clock can distinguish within a second). 3) postsuper(1) deletes the new message, instead of the old message that it should have deleted. -h queue_id Put mail "on hold" so that no attempt is made to deliver it. Move one message with the named queue ID from the named mail queue(s) (default: incoming, active and deferred) to the hold queue. If a queue_id of - is specified, the program reads queue IDs from standard input. Specify "-h ALL" to hold all messages; for example, specify "-h ALL deferred" to hold all mail in the deferred queue. As a safety measure, the word ALL must be specified in upper case. Note: while mail is "on hold" it will not expire when its time in the queue exceeds the maximal_queue_lifetime or bounce_queue_life- time setting. It becomes subject to expiration after it is released from "hold". This feature is available in Postfix 2.0 and later. -H queue_id Release mail that was put "on hold". Move one message with the named queue ID from the named mail queue(s) (default: hold) to the deferred queue. If a queue_id of - is specified, the program reads queue IDs from standard input. Note: specify "postsuper -r" to release mail that was kept on hold for a significant fraction of $maximal_queue_lifetime or $bounce_queue_lifetime, or longer. Specify "-H ALL" to release all mail that is "on hold". As a safety measure, the word ALL must be specified in upper case. This feature is available in Postfix 2.0 and later. -p Purge old temporary files that are left over after system or software crashes. -r queue_id Requeue the message with the named queue ID from the named mail queue(s) (default: hold, incoming, active and deferred). To requeue multiple messages, specify multiple -r command-line options. Alternatively, if a queue_id of - is specified, the program reads queue IDs from standard input. Specify "-r ALL" to requeue all messages. As a safety measure, the word ALL must be specified in upper case. A requeued message is moved to the maildrop queue, from where it is copied by the pickup(8) and cleanup(8) daemons to a new queue file. In many respects its handling differs from that of a new local submission. o The message is not subjected to the smtpd_milters or non_smtpd_milters settings. When mail has passed through an external content filter, this would produce incorrect results with Milter applications that depend on original SMTP connection state information. o The message is subjected again to mail address rewriting and substitution. This is useful when rewriting rules or virtual mappings have changed. The address rewriting context (local or remote) is the same as when the message was received. o The message is subjected to the same content_filter settings (if any) as used for new local mail submissions. This is useful when content_filter settings have changed. Warning: Postfix queue IDs are reused. There is a very small possibility that postsuper(1) requeues the wrong message file when it is executed while the Postfix mail system is running, but no harm should be done. This feature is available in Postfix 1.1 and later. -s Structure check and structure repair. This should be done once before Postfix startup. o Rename files whose name does not match the message file inode number. This operation is necessary after restoring a mail queue from a different machine, or from backup media. o Move queue files that are in the wrong place in the file system hierarchy and remove subdirectories that are no longer needed. File position rearrangements are necessary after a change in the hash_queue_names and/or hash_queue_depth configura- tion parameters. -v Enable verbose logging for debugging purposes. Multiple -v options make the software increasingly verbose. DIAGNOSTICS
Problems are reported to the standard error stream and to syslogd(8). postsuper(1) reports the number of messages deleted with -d, the number of messages requeued with -r, and the number of messages whose queue file name was fixed with -s. The report is written to the standard error stream and to syslogd(8). ENVIRONMENT
MAIL_CONFIG Directory with the main.cf file. BUGS
Mail that is not sanitized by Postfix (i.e. mail in the maildrop queue) cannot be placed "on hold". CONFIGURATION PARAMETERS
The following main.cf parameters are especially relevant to this program. The text below provides only a parameter summary. See post- conf(5) for more details including examples. config_directory (see 'postconf -d' output) The default location of the Postfix main.cf and master.cf configuration files. hash_queue_depth (1) The number of subdirectory levels for queue directories listed with the hash_queue_names parameter. hash_queue_names (deferred, defer) The names of queue directories that are split across multiple subdirectory levels. queue_directory (see 'postconf -d' output) The location of the Postfix top-level queue directory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (see 'postconf -d' output) The mail system name that is prepended to the process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO
sendmail(1), Sendmail-compatible user interface postqueue(1), unprivileged queue operations LICENSE
The Secure Mailer license must be distributed with this software. AUTHOR(S) Wietse Venema IBM T.J. Watson Research P.O. Box 704 Yorktown Heights, NY 10598, USA POSTSUPER(1)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy