Commands.pl

From Organic Design wiki
Revision as of 03:25, 9 December 2005 by Nad (talk | contribs) (The infamous commands.pl)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

sub command {

my ($title, $args) = $_[0] =~ /(.+?)(\((.+)\))?$/g; my $article;

# pon/poff if ($title eq 'ppp') { $article = `ifconfig` } if ($title eq 'pon') { `pon`; $article = `tail -n 1 /var/log/syslog|grep pppd`; } if ($title eq 'poff') { `poff`; $article = `tail -n 3 /var/log/syslog|grep pppd`; }

# syslog if ($title eq 'syslog') { $article = `tail -n 50 /var/log/syslog` }

# Restart if ($title eq 'restart') { my $closed = 0; for ( keys %activePeers ) { my $handle = $activePeers{$_}{handle}; if ( defined $handle ) { $closed++; $select->remove($handle); $handle->close(); } } $server->shutdown(SHUT_RDWR); logAdd "$closed handles closed."; logAdd "Restarting $daemon using: $cmd"; exec "sleep 60; $cmd"; }

else { logAdd $article = "Unknown command: $_[0]" }

return $article; }