X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=8af394b8898d4852b6e9ca0656a3a1c5014e3313;hb=b060a0a3ee72530aa3f10d453186a662b66d7efe;hp=522200da3b8249cb74f3bc492a92fa1862d17331;hpb=27854d917fc31b9f2dd184c24e6f38265a3a09e8;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 522200da..8af394b8 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -17,6 +17,7 @@ use DXUser; use DXVars; use DXDebug; use DXM; +use DXLog; use CmdAlias; use FileHandle; use Carp; @@ -46,7 +47,7 @@ sub new sub start { - my ($self, $line) = @_; + my ($self, $line, $sort) = @_; my $user = $self->{user}; my $call = $self->{call}; my $name = $user->{name}; @@ -74,12 +75,31 @@ sub start my $nchan = DXChannel->get($main::mycall); my @pc16 = DXProt::pc16($nchan, $cuser); DXProt::broadcast_ak1a(@pc16); + Log('DXCommand', "$call connected"); } # # This is the normal command prompt driver # + sub normal +{ + my $self = shift; + my $cmdline = shift; + + my @ans = run_cmd($self, $cmdline); + $self->send(@ans) if @ans > 0; + + # send a prompt only if we are in a prompt state + $self->prompt() if $self->{state} =~ /^prompt/o; +} + +# +# this is the thing that runs the command, it is done like this for the +# benefit of remote command execution +# + +sub run_cmd { my $self = shift; my $user = $self->{user}; @@ -139,18 +159,15 @@ sub normal if ($ans[0]) { shift @ans; - $self->send(@ans) if @ans > 0; } else { shift @ans; if (@ans > 0) { - $self->send($self->msg('e2'), @ans); + unshift @ans, $self->msg('e2'); } else { - $self->send($self->msg('e1')); + @ans = $self->msg('e1'); } } - - # send a prompt only if we are in a prompt state - $self->prompt() if $self->{state} =~ /^prompt/o; + return @ans; } # @@ -192,7 +209,8 @@ sub finish my $nchan = DXChannel->get($main::mycall); my $pc17 = $nchan->pc17($self); DXProt::broadcast_ak1a($pc17); - + + Log('DXCommand', "$call disconnected"); $ref->del() if $ref; }