2 # The rudimentary beginnings of a Spider client which is known to run on ActiveState
5 # It's very scrappy, but it *does* do enough to allow SysOp console access. It also
6 # means that since it's perl, Dirk might pretty it up a bit :-)
10 # Iain Philipps, G0RDI 03-Mar-01
17 # search local then perl directories
19 use vars qw($root $myalias $mycall $clusteraddr $clusterport $data);
21 # root of directory tree for this system
23 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
25 unshift @INC, "$root/perl"; # this IS the right way round!
26 unshift @INC, "$root/local";
38 my $call = uc shift @ARGV if @ARGV;
39 $call = uc $myalias if !$call;
40 my ($scall, $ssid) = split /-/, $call;
41 $ssid = undef unless $ssid && $ssid =~ /^\d+$/;
43 $ssid = 15 if $ssid > 15;
44 $call = "$scall-$ssid";
46 if ($call eq $mycall) {
47 print "You cannot connect as your cluster callsign ($mycall)\n";
52 my $handle = IO::Socket::INET->new(Proto => "tcp",
53 PeerAddr => $clusteraddr,
54 PeerPort => $clusterport);
56 if (-r "$data/offline") {
57 open IN, "$data/offline" or die;
63 print "Sorry, the cluster $mycall is currently off-line\n";
69 $handle->autoflush(1);
70 print $handle "A$call|local\n";
72 # Fork or thread one in / one out .....
75 if ($Config{usethreads}) {
77 # print "Using Thread Method\n";
78 $t = Thread->new(\&dostdin);
83 # print "Using Fork Method\n";
84 die "can't fork: $!" unless defined($childpid = fork());
87 kill 'TERM', $childpid;
97 my ($lastend, $end) = ("\n", "\n");
99 while (defined (my $msg = <$handle>)) {
100 my ($sort, $call, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/;
101 next unless defined $sort;
102 $line =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
105 } elsif ($sort eq 'E' || $sort eq 'B') {
108 # newline ends all lines except a prompt
111 if ($line =~ /^$call de $mycall\s+\d+-\w\w\w-\d+\s+\d+Z >$/o) {
114 my $begin = ($lastend eq "\n") ? '' : "\n";
115 print $begin . $line . $end;
122 while (defined (my $line = <STDIN>)) {
123 print $handle "I$call|$line\n";
124 if ($t && ($line =~ /^b/i || $line =~ /^q/i)) {