]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/dialog/samples/copifuncs/copi.ifreq2
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / dialog / samples / copifuncs / copi.ifreq2
1 # this is the base directory, where the req-files are stored and the
2 # default outbound
3 $flo_path = "/var/spool/ifmail";
4 $outbound = "/outb"; # don't be confused, it means "/var/spool/ifmail/outb"
5
6 # end of configuration #############################################
7
8 # main()
9 #
10 if ((@ARGV < 1) || @ARGV > 2 || $ARGV[0] eq "-?") {
11     &usage;
12 } elsif ($ARGV[1] ne "") {
13     $node = $ARGV[1];
14 }
15 $file = $ARGV[0];
16
17 if (! ($node =~ /\d+:\d+\/\d+/)) {
18     die "Wrong address: $node!!!";
19 }
20
21 ($zone, $netnode) = split (/:/, $node);
22 $reqfile = sprintf("%04x%04x", split(/\//, $netnode));
23
24 if ($reqfile eq "00000000") {
25     print ("can't resolve the fido address \"$node\"\n");
26     &usage;
27 } else {
28     if ( $zone == 2 ) {
29         $reqfile = $flo_path . $outbound . "/" . $reqfile . ".req";
30     } elsif ( $zone < 7 ) {
31         $reqfile = $flo_path . $outbound . ".00$zone/" . $reqfile . ".req";
32     } else {
33         $outbound = "";
34         open (CONFIG, "< $config") || die "can't open $config";
35         while ($_ = <CONFIG>) {
36             if ( /^address.*$zone:.*\@(\w*)/ ) { $outbound = $1; }
37         }
38         if ( $outbound eq "" ) {
39             die "No Zone $zone found in $config";
40         }
41         $reqfile = $flo_path . "/$outbound/" . $reqfile . ".req";
42     }
43
44     # seperate the file names of the first argument
45     @files = split (/\s+/, $ARGV[0]);
46
47     # open the flofile for appending
48     open(FLOFILE, ">>" . $reqfile) || die "can't open $reqfile";
49         while (@files) {
50             print (FLOFILE shift(@files), "\n");
51         }
52     close(FLOFILE);
53
54     print ("--- fido request $ver ---------------------------\n");
55     print ("requesting \"$file\" from fido-node $node\n");
56     print ("--- executing ifstat .. ------------------------\n");
57     system("ifstat");
58 }
59
60 #
61 # subroutine "usage"
62 #
63 sub usage {
64     printf ("--- fido request %s -------------\n", $ver);
65     printf ("usage: ifreq <file> [<3-d address>]\n");
66     printf ("e.g. : ifreq FILES 2:2410/305\n");
67     exit 1;
68 }