#!/usr/bin/perl # a .qmail condredirect clone for use with courier # this will hopefully get somewhat better over its lifespan, but at least this works $addr = shift; while($cmd = shift) { $ccmd .= "$cmd "; } while($in = <>) { $msg .= $in; } open(FH, "|$ccmd"); print FH $msg; close(FH); $exit = $?; #slog("cmd: [$ccmd] exit code: $exit"); exit(111) if($exit == 111); if($exit == 0) { open(FH,"|/usr/lib/sendmail $addr"); print FH $msg; close(FH); exit(99); } exit(0); sub slog { $log = shift; open(LOG,">>/tmp/condredirect.log"); print LOG "$log\n"; close(LOG); }