1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 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();
|