diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-03-03 11:32:53 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-03-03 11:32:53 +0100 |
commit | 27ac72d69b605df62e4f56b04ed7aec0c4e4ba1f (patch) | |
tree | b7a45fae3b0d6bfeeb5a600d987c4f8be6ae8a5c /utils/bitlbee-ctl.pl | |
parent | 5e713f695f93f7dc88f225bf6a8cd16e228eff11 (diff) | |
parent | cdb92c53a9e930bc6c685127d13b743872959e75 (diff) |
Merge from Jelmer.
Diffstat (limited to 'utils/bitlbee-ctl.pl')
-rwxr-xr-x | utils/bitlbee-ctl.pl | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/utils/bitlbee-ctl.pl b/utils/bitlbee-ctl.pl new file mode 100755 index 00000000..32f0a81e --- /dev/null +++ b/utils/bitlbee-ctl.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# Simple front-end to BitlBee's administration commands +# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org> + +use IO::Socket; +use Getopt::Long; +use strict; +use warnings; + +my $opt_help; +my $opt_socketfile = "/var/run/bitlbee"; + +sub ShowHelp +{ + print +"bitlbee-ctl.pl [options] command ... + +Available options: + + --ipc-socket=SOCKET Override path to IPC socket [$opt_socketfile] + --help Show this help message + +Available commands: + + die + +"; + exit (0); +} + +GetOptions ( + 'help|h|?' => \&ShowHelp, + 'ipc-socket=s' => \$opt_socketfile + ) or exit(1); + +my $client = IO::Socket::UNIX->new(Peer => $opt_socketfile, + Type => SOCK_STREAM, + Timeout => 10); + +if (not $client) { + print "Error connecting to $opt_socketfile: $@\n"; + exit(1); +} + +my $cmd = shift @ARGV; + +if (not defined($cmd)) { + print "Usage: bitlbee-ctl.pl [options] command ...\n"; + exit(1); +} + +if ($cmd eq "die") { + $client->send("DIE\r\n"); +} else { + print "No such command: $cmd\n"; + exit(1); +} + +$client->close(); |