[Asterisk-Users] Reload Asterisk from php or perl script

Donny Kavanagh kavando at trn.ca
Fri Oct 8 07:56:07 MST 2004


Shoudn't you be able to use the Manager API to connect to Asterisk over
a socket and issue a reload that way.  This way you don't have to worry
about permissions what so ever, other then connection php will make.

The wiki is here http://www.voip-info.org/wiki-Asterisk+Manager+API

It gives this example which should be exactly what you want

<?php 

 $socket = fsockopen("192.168.0.53","5038", $errno, $errstr, $timeout); 
 fputs($socket, "Action: Login\r\n"); 
 fputs($socket, "UserName: admin\r\n"); 
 fputs($socket, "Secret: blabla\r\n\r\n"); 

 fputs($socket, "Action: Command\r\n"); 
 fputs($socket, "Command: reload\r\n\r\n"); 
 $wrets=fgets($socket,128); 

?> 


Donny



-----Original Message-----
From: Justin B. Newman [mailto:justin.newman at binhost.com] 
Sent: Friday, October 08, 2004 9:54 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] Reload Asterisk from php or perl script


On 10/8/2004, "Dee Lowndes" <dee at asyouneed.com> wrote:
>Hi,
>
>	I am looking for a basic script that can reload asterisk from
>php or perl via a web browser.
>
>I have tried exec( asterisk -rx reload ) and shell_exec( <same cmd> )
>with php but there seems to be a permission issue with asterisk that
>stops these working. I was just wondering if anyone has a way around
>this with perl or php.
>

Dee, 

If Asterisk is running as a different user than your web server, then
you're
not going to be able to use those scripts "outta the box".  Running
Asterisk
as the same user as your web server would probably be considered a
horribly
insecure configuration, at best.

The alternative is to explore options for allowing your webserver to run
programs as different userid's.  If you're running Apache, this page may
help:
   http://httpd.apache.org/docs/suexec.html

Good luck!

Yours,

-jbn
Justin B Newman
BinFone Telecom
(Offering SIP and IAX termination and origination at
http://www.binfone.com)
_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list