Difference between revisions of "Commands.pl"
(bug fix) |
(update) |
||
| Line 1: | Line 1: | ||
| + | |||
| + | # TMP | ||
| + | # command() should be generic and declared in wikid.pl | ||
| + | # - can use command_name() | ||
| + | # - maybe we can execute lambda style now | ||
| + | |||
sub command { | sub command { | ||
| Line 15: | Line 21: | ||
# Restart | # Restart | ||
| + | # - For some reason it fucks up if it doesn't wait for a minute | ||
| + | # - 2005-12-09 tried closing handles and server->shutdown(SHUT_RDWR) but made no difference | ||
elsif ($title eq 'restart') { | elsif ($title eq 'restart') { | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
logAdd "Restarting $daemon using: $cmd"; | logAdd "Restarting $daemon using: $cmd"; | ||
exec "sleep 60; $cmd"; | exec "sleep 60; $cmd"; | ||
} | } | ||
| + | |||
| + | # Version | ||
| + | elsif ($title eq 'version') { $article = "OS: $^O\nPERL: $ver\nDaemon: $cmd\n" } | ||
else { logAdd $article = "Unknown command: $command" } | else { logAdd $article = "Unknown command: $command" } | ||
Revision as of 23:43, 13 December 2005
- TMP
- command() should be generic and declared in wikid.pl
- - can use command_name()
- - maybe we can execute lambda style now
sub command {
my $command = shift; $command =~ /(.+?)(\((.+)\))?$/; my ($title, $args) = ( $1, $2 ); my $article;
# pon/poff if ($title eq 'ppp') { $article = `ifconfig` } elsif ($title eq 'pon') { `pon`; $article = `tail -n 1 /var/log/syslog|grep pppd`; } elsif ($title eq 'poff') { `poff`; $article = `tail -n 3 /var/log/syslog|grep pppd`; }
# syslog elsif ($title eq 'syslog') { $article = `tail -n 50 /var/log/syslog` }
# Restart # - For some reason it fucks up if it doesn't wait for a minute # - 2005-12-09 tried closing handles and server->shutdown(SHUT_RDWR) but made no difference elsif ($title eq 'restart') { logAdd "Restarting $daemon using: $cmd"; exec "sleep 60; $cmd"; }
# Version elsif ($title eq 'version') { $article = "OS: $^O\nPERL: $ver\nDaemon: $cmd\n" }
else { logAdd $article = "Unknown command: $command" }
return $article; }



