3 # Implement an external "show/dx" command
5 # Copyright (c) 1998-2023 Dirk Koopman G1TLH
10 # search local then perl directories
12 # root of directory tree for this system
14 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
16 unshift @INC, "$root/perl"; # this IS the right way round!
17 unshift @INC, "$root/local";
19 our $local_data = "$root/local_data";
20 our $data = "$root/data";
34 $Spot::spotcachedays = 0;
46 my $self = bless {_nospawn => 1, width => 80, call=>$call, lang=>'en' }, 'DXCommandmode' ;
47 $self->{user} = DXUser::get($call);
50 while ($ARGV[0] =~ /^-+/) {
51 if ($ARGV[0] =~ /^-+[?h]/i) {
55 $wantreal = 1 if $ARGV[0] =~ /^-+r/i;
56 $ve7cc = 1 if $ARGV[0] =~ /^-+v/i;
57 if ($ARGV[0] =~ /^-+w$/i && $ARGV[1] && $ARGV[1] =~ /^\d+$/) {
58 $self->{width} = $ARGV[1];
61 if ($ARGV[0] =~ /^-+c/i && $ARGV[1] && is_callsign(uc $ARGV[1])) {
63 my $ref = DXUser::get($call);
65 $self->{call} = $call;
70 $self->{user}->wantgrid(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wg)/i;
71 $self->{user}->wantusstate(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wu)/i;
72 $self->{user}->wantdxitu(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wi)/i;
73 $self->{user}->wantdxcq(1), ++$wantreal if $self->{user} && $ARGV[0] =~ /^-+(wa|wc)/i;
78 $self->{ve7cc} = $ve7cc;
80 $dxdir = "/spider/cmd/show";
82 $s = readfilestr($dxdir, $dxcmd);
88 $expr = join ' ', @ARGV if @ARGV;
93 $myexpr = 'real ' . $myexpr if $wantreal && $myexpr !~ /\breal\b/;
97 last unless defined $myexpr;
99 last if $myexpr =~ /^q$/i;
100 $myexpr = 'real ' . $myexpr if $wantreal && $myexpr !~ /\breal\b/;
103 my @out = map {"$_\n"} handle($self, $myexpr);
104 shift @out; # remove return code
109 exit @out > 0 ? 0 : 1;
113 print qq{A static TEST Program that allows standalone sh/dx queries
114 from the command line.
120 showdx -v -c g1tlh by g1tlh
121 showdx -w 132 -wc -wg -wu 50 on 40m
126 -c <callsign>: pretend to be this callsign
127 -r: set 'real' mode (a.k.a show/fdx) (saves typing 'real ' in the query)
128 -v: output in VE7CC computer friendly mode.
129 -w <width>: use this width
130 -wc: set want cq zones
131 -wg: set want grid squares
132 -wi: set want itu zones
133 -wu: set want US states
134 -wa: set all of the above
136 NOTE: setting any of -wc, -wg, -wi, -wu flags implies adding 'real ' to
137 the query, if not already present.