Hi all,
I have a small problem to execute Asterisk Commands in Asterisk
Manager using PHP.
I am able to run all Asterisk Manager command but the problem is
comming with asterisk command.
here is the code i am trying to run.
<?php
$socket = fsockopen("localhost","5038", $errno, $errstr,
$timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: 1212\r\n");
fputs($socket, "Secret: 1212\r\n\r\n");
fputs($socket, "Action: Command\r\n");
fputs($socket, "Command: reload\r\n\r\n"); #Working well
fputs($socket, "Command: show channels\r\n\r\n"); #Not working
Working well
fputs($socket, "Command: 'show channels'\r\n\r\n"); #Not
working Working well
$wrets=fgets($socket,128);
?>
If you see in my code when i am calling only "reload" command working
but when i am trying to call piar command it is just prompting :
== Manager '1212' logged off from localhost
without showing channels
Please advice me to solve this problem.
--
Thank You,
Code Lover
AFAIK you need to use different actions for each command., sending 3 commands in the same action wont work. I have no problems to issue commands, originates etc. On 12/28/05, Code Lover <lateef.np@gmail.com> wrote:> > Hi all, > > I have a small problem to execute Asterisk Commands in Asterisk > Manager using PHP. > I am able to run all Asterisk Manager command but the problem is > comming with asterisk command. > > here is the code i am trying to run. > > <?php > $socket = fsockopen("localhost","5038", $errno, $errstr, $timeout); > fputs($socket, "Action: Login\r\n"); > fputs($socket, "UserName: 1212\r\n"); > fputs($socket, "Secret: 1212\r\n\r\n"); > fputs($socket, "Action: Command\r\n"); > fputs($socket, "Command: reload\r\n\r\n"); #Working well > fputs($socket, "Command: show channels\r\n\r\n"); #Not working Working > well > fputs($socket, "Command: 'show channels'\r\n\r\n"); #Not working Working > well > $wrets=fgets($socket,128); > > ?> > > > > If you see in my code when i am calling only "reload" command working > but when i am trying to call piar command it is just prompting : > == Manager '1212' logged off from localhost > > without showing channels > > Please advice me to solve this problem. > -- > Thank You, > Code Lover > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > Asterisk-Users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- "Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20051228/de322602/attachment.htm
try this
<?php
$socket = fsockopen("localhost","5038", $errno, $errstr,
$timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: 1212\r\n");
fputs($socket, "Secret: 1212\r\n\r\n");
fputs($socket, "Action: Command\r\n");
fputs($socket, "Command: reload\r\n\r\n");
* fputs($socket, "Action: Command\r\n");*
fputs($socket, "Command: show channels\r\n\r\n");
$wrets=fgets($socket,128);
?>
Code Lover wrote:> Hi all,
>
> I have a small problem to execute Asterisk Commands in Asterisk
> Manager using PHP.
> I am able to run all Asterisk Manager command but the problem is
> comming with asterisk command.
>
> here is the code i am trying to run.
>
> <?php
> $socket = fsockopen("localhost","5038", $errno,
$errstr, $timeout);
> fputs($socket, "Action: Login\r\n");
> fputs($socket, "UserName: 1212\r\n");
> fputs($socket, "Secret: 1212\r\n\r\n");
> fputs($socket, "Action: Command\r\n");
> fputs($socket, "Command: reload\r\n\r\n"); #Working well
> fputs($socket, "Command: show channels\r\n\r\n"); #Not working
Working well
> fputs($socket, "Command: 'show channels'\r\n\r\n"); #Not
working Working well
> $wrets=fgets($socket,128);
>
> ?>
>
>
>
> If you see in my code when i am calling only "reload" command
working
> but when i am trying to call piar command it is just prompting :
> == Manager '1212' logged off from localhost
>
> without showing channels
>
> Please advice me to solve this problem.
> --
> Thank You,
> Code Lover
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>