Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function surpress { /bin/rm --force /tmp/surpress.out 2> /dev/null; ${1+"$@"} > /tmp/surpress.out 2>&1 || cat /tmp/surpress.out; /bin/rm /tmp/surpress.out; }
- surpress foo -a bar
- OUTPUT=`tempfile`
- program_we_want_to_capture &2>1 > $OUTPUT
- [ $? -ne 0 ]; then
- cat $OUTPUT
- exit 1
- fi
- rm $OUTPUT
- #!/bin/bash
- the_command 2>&1 | awk '
- BEGIN
- {
- # Initialize our error-detection flag.
- ErrorDetected = 0
- }
- # Following are regex that will simply skip all lines
- # which are good and we never want to see
- / Added UserList source/ ||
- / Added User/ ||
- / init domainlist / ||
- / init iplist / ||
- / init urllist / ||
- / loading dbfile / ||
- /^$/ {next} # Uninteresting message. Skip it.
- # Following are lines that we good and we always want to see
- / INFO: ready for requests /
- {
- print " " $0 # Expected message we want to see.
- next
- }
- # any remaining lines are unexpected, and probably error messages. These will be printed out and highlighted.
- {
- print "->" $0 # Unexpected message. Print it
- ErrorDetected=1
- }
- END
- {
- if (ErrorDetected == 1) {
- print "Unexpected messages ("->") detected in execution."
- exit 2
- }
- }
- '
- exit $?
- out=`command args...` || echo $out
Add Comment
Please, Sign In to add comment