summaryrefslogtreecommitdiff
path: root/Tools/schnitt/vdr-remote.pl
blob: 32d408e0d5a101d552dd417d81643445ee6d4d7e (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
38
39
40
#!/usr/bin/perl -w

use strict;
use Socket;

my ($dest, $port, $iaddr, $paddr, $proto, $line);

$dest = "localhost";
$port = "2001";

$iaddr = inet_aton($dest)                   || Error("no host: $dest");
$paddr = sockaddr_in($port, $iaddr);

$proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || Error("socket: $!");
connect(SOCK, $paddr)                       || Error("connect: $!");
select (SOCK); $| = 1;
$a=<SOCK>;

for (;;)
  {
    open (FI,"/tmp/vdr-keys");
    while (<FI>)
      {
	chomp;
	print "$_\r\n";
	$a=<SOCK>;
      }
    close (FI);
  }

print "quit\r\n";
$a=<SOCK>;
close (SOCK)                                || Error("close: $!");

sub Error
{
  print STDERR "@_\n";
  exit 0;
}