Difference between revisions of "Commands.pl"
(update) |
(Fix qx bug) |
||
| Line 13: | Line 13: | ||
# pon/poff | # pon/poff | ||
| − | if ($title eq 'ppp') { $article = `ifconfig` } | + | if ($title eq 'ppp') { $article = `ifconfig` } |
| − | elsif ($title eq 'pon') { `pon`; $article = `tail -n 1 /var/log/syslog|grep pppd`; } | + | 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`; } | + | elsif ($title eq 'poff') { `poff`; $article = `tail -n 3 /var/log/syslog|grep pppd`; } |
# syslog | # syslog | ||
| − | elsif ($title eq 'syslog') { $article = `tail -n 50 /var/log/syslog` } | + | elsif ($title eq 'syslog') { $article = `tail -n 50 /var/log/syslog` } |
| + | |||
| + | # peer log | ||
| + | elsif ($title eq 'peerlog') { $article = qx( tail -n 50 $peer.log ) } | ||
| + | |||
| + | # reboot | ||
| + | elsif ($title eq 'reboot') { $article = `shutdown -r now` } | ||
| + | |||
| + | # shutdown | ||
| + | elsif ($title eq 'shutdown') { $article = `halt` } | ||
# Restart | # Restart | ||
Revision as of 02:38, 14 January 2006
- 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` }
# peer log elsif ($title eq 'peerlog') { $article = qx( tail -n 50 $peer.log ) }
# reboot elsif ($title eq 'reboot') { $article = `shutdown -r now` }
# shutdown elsif ($title eq 'shutdown') { $article = `halt` }
# 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; }



