simplified version
[spider.git] / cmd / demonstrate.pl
1 #!/usr/bin/perl
2 #
3 # pretend that you are another user, execute a command
4 # as that user, then send the output back to them.
5 #
6 # This is for educating users....
7 #
8 # Copyright (c) 2002 Dirk Koopman G1TLH
9 #
10 my ($self, $line) = @_;
11
12 my ($call, $newline) = split /\s+/, $line, 2;
13 $call = uc $call;
14 my $dxchan = DXChannel->get($call);
15
16 return (1, $self->msg('e7', $call)) unless $dxchan;
17 if ($self->remotecmd) {
18         Log('DXCommand', "$mycall is trying to 'demo' to $call remotely");
19         return (1, $self->msg('e5'));
20 }
21 if ($self->priv < 9) {
22         Log('DXCommand', "$mycall is trying to 'demo' to $call locally");
23         return (1, $self->msg('e5'));
24 }
25 Log('DXCommand', "demo '$newline' to $call by $mycall");
26 my @in = $dxchan->run_cmd($newline);
27
28 $dxchan->send($newline, @in);
29
30 return (1, map { "->$call: $_" } @in);