blob: 7f8bc0e6c50939c4e9c5163317003c8f51f2b285 (
plain)
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
|
#!/usr/bin/perl -w
# Author: Ferdi Franceschini
#
# dpid control program
# Currently allows
# register: Tells dpid to register all available dpis
# stop: Stops dpid.
use strict;
use IO::Socket::INET;
# Get socket directory name
#open(DSD, "<$ENV{HOME}/.dillo/dpi_socket_dir");
#my $dir = <DSD>;
#close(DSD);
# Get dpid's listening port from saved file
open(DSD, "<$ENV{HOME}/.dillo/dpid_comm_keys");
my $port = <DSD>;
close(DSD);
print "Got: localhost:$port\n";
my $socket = IO::Socket::INET->new(Peer => "localhost:$port", Type => SOCK_STREAM, Timeout => 1000 ) or die "new: $@";
$socket->autoflush(1);
my %dpi_command = (
"register" => "<dpi cmd='register_all' '>",
"stop" => "<dpi cmd='DpiBye' '>",
);
if ( $#ARGV == 0 && exists($dpi_command{$ARGV[0]}) ) {
print $socket $dpi_command{$ARGV[0]};
} else {
close($socket);
print "Usage: dpidc register|stop\n";
}
|