File: SATest.pl

package info (click to toggle)
spamassassin 4.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,732 kB
  • sloc: perl: 89,143; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (32 lines) | stat: -rwxr-xr-x 691 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

my %opts;
my @args;
{
  my $opts = 1;
  foreach (@ARGV) {
    if ($opts) {
      $opts     =  0 if /^--$/;
      $opts{$1} = $2 if /^-([a-zA-Z])(.+)$/;
    } else {
      push (@args, $_);
    }
  }
}

my $mode = $opts{'M'};
if ($mode eq 'redirect') {
  my $stdout = $opts{'o'}   || die "No -o";
  my $stderr = $opts{'O'}   || die "No -O";
  open (STDOUT, ">$stdout") || die "Could not redirect STDOUT to $stdout: $!";
  open (STDERR, ">$stderr") || die "Could not redirect STDERR to $stderr: $!";
  
  select STDERR; $| = 1;
  select STDOUT; $| = 1;

  exec { $args[0] } @args;
  die "Could not exec " . join(' ', @args) . ": $!";
}
else {
  die "Unknown mode: $mode\n";
}