ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/myhttpd/shell.pl
(Generate patch)

Comparing Coro/myhttpd/shell.pl (file contents):
Revision 1.11 by root, Tue Aug 14 14:56:22 2001 UTC vs.
Revision 1.15 by root, Sun Aug 19 23:57:52 2001 UTC

9use Text::Abbrev; 9use Text::Abbrev;
10 10
11my $last_ts = time; 11my $last_ts = time;
12 12
13my %complete; 13my %complete;
14my @commands = qw(quit squit refresh country restart block info eval); 14my @commands = qw(quit squit refresh country restart block info print);
15 15
16abbrev \%complete, @commands; 16abbrev \%complete, @commands;
17 17
18sub shell { 18sub shell {
19 my $fh = shift; 19 my $fh = shift;
20 20
21 while (defined (print $fh "cmd> "), $_ = <$fh>) { 21 while (defined (print $fh "cmd> "), $_ = <$fh>) {
22 s/\015?\012$//; 22 s/\015?\012$//;
23 if (s/^(\S+)\s*// && (my $cmd = $complete{$1})) { 23 if (s/^(\S+)\s*// && (my $cmd = $complete{$1})) {
24 if ($cmd eq "quit") { 24 if ($cmd eq "quit") {
25 print "bye bye.\n";#d# 25 print $fh "bye bye.\n";#d#
26 last; 26 last;
27 } elsif ($cmd eq "squit") { 27 } elsif ($cmd eq "squit") {
28 print $fh "server quit.\n";#d#
28 Event::unloop; 29 Event::unloop;
29 last; 30 last;
30 } elsif ($cmd eq "eval") { 31 } elsif ($cmd eq "print") {
31 my @res = eval $_; 32 my @res = eval $_;
32 print $fh "eval: $@\n" if $@; 33 print $fh "eval: $@\n" if $@;
33 print $fh "RES = ", (join " : ", @res), "\n"; 34 print $fh "RES = ", (join " : ", @res), "\n";
34 } elsif ($cmd eq "block") { 35 } elsif ($cmd eq "block") {
35 print "blocked '$_'\n";#d# 36 print "blocked '$_'\n";#d#
50 printf $fh "(%.1f bytes/s)\n", $::written / ($::NOW - $last_ts); 51 printf $fh "(%.1f bytes/s)\n", $::written / ($::NOW - $last_ts);
51 ($last_ts, $::written) = ($::NOW, 0); 52 ($last_ts, $::written) = ($::NOW, 0);
52 } elsif ($cmd eq "refresh") { 53 } elsif ($cmd eq "refresh") {
53 do "config.pl"; 54 do "config.pl";
54 print $fh "config.pl: $@\n" if $@; 55 print $fh "config.pl: $@\n" if $@;
55 read_blocklist; 56 read_blockuri;
57 read_blockref;
56 } elsif ($cmd eq "restart") { 58 } elsif ($cmd eq "restart") {
57 $::RESTART = 1; 59 $::RESTART = 1;
58 unloop; 60 unloop;
59 print $fh "restarting, cu!\n"; 61 print $fh "restarting, cu!\n";
60 last; 62 last;
68} 70}
69 71
70# bind to tcp port 72# bind to tcp port
71if ($CMDSHELL_PORT) { 73if ($CMDSHELL_PORT) {
72 my $port = new Coro::Socket 74 my $port = new Coro::Socket
73 LocalAddr => "127.0.0.1", 75 #LocalAddr => "127.0.0.1",
74 LocalPort => $CMDSHELL_PORT, 76 LocalPort => $CMDSHELL_PORT,
75 ReuseAddr => 1, 77 ReuseAddr => 1,
76 Listen => 1, 78 Listen => 1,
77 or die "unable to bind cmdshell port: $!"; 79 or die "unable to bind cmdshell port: $!";
78 80

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines