[asterisk-users] Read Telnet Packet

A J Stiles asterisk_list at earthshod.co.uk
Fri Oct 11 02:58:33 CDT 2013


On Friday 11 October 2013, akhilesh chand wrote:
> Dear All,
> 
> I want to read telnet packet continuously whenever a new call is originated
> and store into a variable after that pass into window server. I have
> written a Perl script to read telnet packet but problem is that whenever I
> executed Perl script then got a telnet packet( mean Only when i execute
> Perl script) here I want to put scheduler,event or other technique whenever
> a new call will come Perl script automatically run.

This is really a Perl question, not an Asterisk question, and you might have 
more joy asking on a Perl list or forum.

Anyway, there are two ways to accomplish what you want.  The easy way is to 
have inetd start your Perl script whenever a packet is sent to a particular 
port; when the script starts, its STDIN and STDOUT will already be connected 
to the port.  The other way is to have your Perl script run as a daemon; then 
fork off a clone of itself to deal with requests as they come in.  After a 
fork, the child process will inherit a copy of the socket object; and this 
will persist even after you undef it in the parent process.

If you want to invoke a Perl script from within the dialplan, you can either 
use a full-on AGI script  (which will even allow you to pass variables back 
and forth and do other funky stuff)  or use System() for a "quick and dirty" 
call to a script that doesn't need to send anything back.

-- 
AJS

Answers come *after* questions.



More information about the asterisk-users mailing list