All pastes #812442 Raw Edit

dechat

public text v1 · immutable
·published 2007-12-11 19:49 UTC
rendered paste body
#!/usr/bin/env perl
# Send arbitrary messages to a decoder

use IO::Socket;

if($#ARGV != 1) {
    die "Usage: $0 IP address \n";
}

print "Message: \n";
$input = &getline();
chomp($input);

sub getline()
{
my $input;
my $char;
while ($char ne "\n")
	{
	$char = getc(STDIN);
	$input .= $char;
	}
	return $input;
}
sub sendmessage()
{
# Open a socket to the decoder
$sock=new IO::Socket::INET->new(PeerPort=>4200, Proto=>'udp', PeerAddr=>$ARGV[0]);

die "socket error: $!\n" unless $sock;

$msg = pack "C25", (
    0x80, 0xe3, 0x00, 0x00, 0x47, 0x5e, 0xd3, 0xd0, 
    0x41, 0x66, 0x67, 0xc2, 0x0c, 0x00, 0x00, 0x00,
    0x72, 0x00, 0x00, 0x00, 0xff, 0x04, 0x00, 0x00, 
    0x00);

$msg .= $input;
$msg .= pack "x";
$sock->send($msg);
# Close socket x`
close($sock);
}
}