bd7696f8682ead963e4360d184e99d58cdff5a0c
[spider.git] / perl / showdx
1 #!/usr/bin/perl
2 #
3 # Implement an external "show/dx" command
4 #
5 # Copyright (c) 1998-2000 Dirk Koopman G1TLH
6 #
7 # $Id$
8 #
9
10 # search local then perl directories
11 BEGIN {
12         # root of directory tree for this system
13         $root = "/spider"; 
14         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
15         
16         unshift @INC, "$root/perl";     # this IS the right way round!
17         unshift @INC, "$root/local";
18 }
19
20 use IO::Handle;
21 use DXUtil;
22 use Bands;
23 use Spot;
24 use VE7CC;
25
26 $dxdir = "/spider/cmd/show";
27 $dxcmd = "dx.pl";
28 $s = readfilestr($dxdir, $dxcmd);
29 $dxproc = eval "sub { $s }";
30 die $@ if $@;
31
32 STDOUT->autoflush(1);
33 Spot::init();
34 Bands::load();
35
36 $expr = join ' ', @ARGV if @ARGV;
37
38 for (;;) {
39         if ($expr) {
40                 $myexpr = $expr;
41         } else {
42                 print "show/dx: ";
43                 $myexpr = <STDIN>;
44                 last unless defined $myexpr;
45                 chomp $myexpr;
46                 last if $myexpr =~ /^q$/i;
47         }
48         my @out = map {"$_\n"} &$dxproc(undef, $myexpr);
49         shift @out;   # remove return code
50         print @out;
51         last if $expr;
52 }
53 exit(0);
54