diff options
Diffstat (limited to 'samples/copifuncs/copi.ifreq2')
-rwxr-xr-x | samples/copifuncs/copi.ifreq2 | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/samples/copifuncs/copi.ifreq2 b/samples/copifuncs/copi.ifreq2 new file mode 100755 index 000000000000..9ee78ff73fe2 --- /dev/null +++ b/samples/copifuncs/copi.ifreq2 @@ -0,0 +1,68 @@ +# this is the base directory, where the req-files are stored and the +# default outbound +$flo_path = "/var/spool/ifmail"; +$outbound = "/outb"; # don't be confused, it means "/var/spool/ifmail/outb" + +# end of configuration ############################################# + +# main() +# +if ((@ARGV < 1) || @ARGV > 2 || $ARGV[0] eq "-?") { + &usage; +} elsif ($ARGV[1] ne "") { + $node = $ARGV[1]; +} +$file = $ARGV[0]; + +if (! ($node =~ /\d+:\d+\/\d+/)) { + die "Wrong address: $node!!!"; +} + +($zone, $netnode) = split (/:/, $node); +$reqfile = sprintf("%04x%04x", split(/\//, $netnode)); + +if ($reqfile eq "00000000") { + print ("can't resolve the fido address \"$node\"\n"); + &usage; +} else { + if ( $zone == 2 ) { + $reqfile = $flo_path . $outbound . "/" . $reqfile . ".req"; + } elsif ( $zone < 7 ) { + $reqfile = $flo_path . $outbound . ".00$zone/" . $reqfile . ".req"; + } else { + $outbound = ""; + open (CONFIG, "< $config") || die "can't open $config"; + while ($_ = <CONFIG>) { + if ( /^address.*$zone:.*\@(\w*)/ ) { $outbound = $1; } + } + if ( $outbound eq "" ) { + die "No Zone $zone found in $config"; + } + $reqfile = $flo_path . "/$outbound/" . $reqfile . ".req"; + } + + # seperate the file names of the first argument + @files = split (/\s+/, $ARGV[0]); + + # open the flofile for appending + open(FLOFILE, ">>" . $reqfile) || die "can't open $reqfile"; + while (@files) { + print (FLOFILE shift(@files), "\n"); + } + close(FLOFILE); + + print ("--- fido request $ver ---------------------------\n"); + print ("requesting \"$file\" from fido-node $node\n"); + print ("--- executing ifstat .. ------------------------\n"); + system("ifstat"); +} + +# +# subroutine "usage" +# +sub usage { + printf ("--- fido request %s -------------\n", $ver); + printf ("usage: ifreq <file> [<3-d address>]\n"); + printf ("e.g. : ifreq FILES 2:2410/305\n"); + exit 1; +} |