fix console.pl max scroll depth
[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 my $mycall = $self->call;
16
17 return (1, $self->msg('e7', $call)) unless $dxchan;
18 return (1, $self->msg('e31', $call)) unless $dxchan->is_user;
19 if ($self->remotecmd || $self->inscript) {
20         Log('DXCommand', "$mycall is trying to 'demo' to $call remotely");
21         return (1, $self->msg('e5'));
22 }
23 if ($self->priv < 9) {
24         Log('DXCommand', "$mycall is trying to 'demo' to $call locally");
25         return (1, $self->msg('e5'));
26 }
27 Log('DXCommand', "demo '$newline' to $call by $mycall");
28 my @in = $dxchan->run_cmd($newline);
29
30 $dxchan->send($newline, @in);
31
32 return (1, map { "->$call: $_" } @in);