Shut up a flood of GLib-related compiler warnings.
[bitlbee.git] / utils / bitlbee-ctl.pl
blob32f0a81ef3f86206122baed829007f17a2905d61
1 #!/usr/bin/perl
2 # Simple front-end to BitlBee's administration commands
3 # Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
5 use IO::Socket;
6 use Getopt::Long;
7 use strict;
8 use warnings;
10 my $opt_help;
11 my $opt_socketfile = "/var/run/bitlbee";
13 sub ShowHelp
15 print
16 "bitlbee-ctl.pl [options] command ...
18 Available options:
20 --ipc-socket=SOCKET Override path to IPC socket [$opt_socketfile]
21 --help Show this help message
23 Available commands:
25 die
28 exit (0);
31 GetOptions (
32 'help|h|?' => \&ShowHelp,
33 'ipc-socket=s' => \$opt_socketfile
34 ) or exit(1);
36 my $client = IO::Socket::UNIX->new(Peer => $opt_socketfile,
37 Type => SOCK_STREAM,
38 Timeout => 10);
40 if (not $client) {
41 print "Error connecting to $opt_socketfile: $@\n";
42 exit(1);
45 my $cmd = shift @ARGV;
47 if (not defined($cmd)) {
48 print "Usage: bitlbee-ctl.pl [options] command ...\n";
49 exit(1);
52 if ($cmd eq "die") {
53 $client->send("DIE\r\n");
54 } else {
55 print "No such command: $cmd\n";
56 exit(1);
59 $client->close();