[Asterisk-Users] perl --> manager problem

mattf mattf at vicimarketing.com
Wed Nov 26 09:01:48 MST 2003


Does it work through the command line? telnetting to your Asterisk box to
the Manager interface?

In you perl script are you using Net::Telnet to connect? or the
Asterisk::Manager?

I have had several issues with the Asterisk::Manager module so I switched to
Net::Telnet and it works every time.

Here's some sample Telnet Perl Code for recording(monitor):

	use Net::Telnet;
	$server_ip = 'asterisk.somedomain.com'; # IP address or domain name
of Asterisk box
	$ASTmgrUSERNAME = 'user';
	$ASTmgrSECRET= 'pass';
	$t = new Net::Telnet (Port => 5038,
						  Prompt => '/.*[\$%#>] $/',
						  Output_record_separator =>
'',);
	$t->open("$server_ip");
	$t->waitfor('/0\n$/');			# wait for connect
	$t->print("Action: Login\nUsername: $ASTmgrUSERNAME\nSecret:
$ASTmgrSECRET\n\n");
	$t->waitfor('/Authentication accepted/');		# print auth
accepted
		$originate_command  = '';
		$originate_command .= "Action: Monitor\n";
		$originate_command .= "Channel: Zap/1-1\n";
		$originate_command .= "File: new_recording_1-1\n";
		$originate_command .= "\n";
	@outside_dial = $t->cmd(String => "$originate_command", Prompt =>
'/Response: Success.*/'); 
	$t->print("Action: Logoff\n\n");	#logoff
	$ok = $t->close;


Hope that helps,

MATT---




-----Original Message-----
From: zoa [mailto:zoachien at securax.org]
Sent: Wednesday, November 26, 2003 10:29 AM
To: asterisk-users at lists.digium.com
Subject: [Asterisk-Users] perl --> manager problem


I am having some issues when trying to connect with perl to the asterisk 
manager and doing an "IAX2 show channels".

If i do that on a server that is heavily loaded, i sometimes get some 
events instead of the channels i asked for.

Any suggestions how i could fix that ?

zoa.

_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users



More information about the asterisk-users mailing list