I want to create a script with perl or php, that send packet from asterisk to socket listing.
I use trixbox and i install the perl-Net-Telnet library with this command :
yum -y install perl-Net-Telnet
the script is located in this directory :
/var/lib/asterisk/agi-bin/
testPerl.pl
#!/usr/bin/perl -w
$server_ip='10.0.10.11';
$tn = new Net::Telnet (Port => 30000,
Prompt => '/.*[\$%#>] $/',
Output_record_separator => '',
Errmode => 'return'
);
#Connect
$tn->open("$server_ip");
$tn->print("Test");
exit;
In the dialplan i wrote :
exten => 52,1,agi(testPerl.pl)
Other script that don’t work …
#!/usr/bin/perl
use IO::Socket;
IO::Socket::INET->new(PeerAddr => “10.0.10.11” . (defined $ARGV[1] ? $ARGV[1] : “30000”), Proto => “tcp”)->send(“bye”,MSG_OOB);
Can you help me ?? please.