Hi folks I'm writing a script to be called from exim to allow multiple virus scanners to be used, and I'm wondering what the best way to do it is.
My script as it stands is below, and I'm using qx{}, to capture the output, but want to also capture the called program's exit code. Suggestions welcome on good style and technique. Gary #!/bin/perl -w # called from exim passing a directory name as argument # calls Sophos Sweep and clamscan on the directory die "Usage: $0 <message_dir>" unless $ARGV[0]; # cmd - command to call # viri - result code if virus found # regex - regex to extract virus lines my %engines={'sweep'=>{'cmd'=>'/usr/local/bin/sweep -all -rec', 'viri'=>3, 'regex'=>'found'}, 'clamscan'=>{'cmd'=>'/usr/bin/clamscan --quiet --stdout -r --no-summary -i', 'viri'=>1, 'regex'=>'found'} }; chdir $ARGV[0] || die "$0: cannot chdir: $!\n"; foreach my $engine (%engines) { my @output=qx{$engine->{'cmd'} .}; # check for result code to indicate success/failure/virus found etc # if virus, return lines reporting it from @output # use map/grep/whatever to extract lines. } -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>