AMI not working to fire command

Hello,

I hv asterisk running properly. I want to connect AMI through php file.
I have created the php file. and when I try to run the php file, it is getting connected to asterisk. But the command is not getting fired.

manager.conf

testami.php

CLI output

[quote]*CLI>
*CLI> == Manager ‘test’ logged on from 192.168.1.x
== Manager ‘test’ logged off from 192.168.1.x
[/quote]

-Thanks

Does the message “Manager ‘test’ logged off from 192.168.1.x” happens 30s after you first try to login? Also did you put this user’s credential info in manager.conf with the correct host restrictions? And even if this file is up to date you need to reload the manager module (I think this is just “manager reload”).

For more info on if this user is even known by AMI you can type “manager show ?” at the CLI and poke around and see how things are set up.

testami.php

CLI output

[quote]*CLI>
*CLI> == Manager ‘test’ logged on from 192.168.1.x
== Manager ‘test’ logged off from 192.168.1.x
[/quote]

You’re missing a \r\n.

Change
fputs($socket, “Channel: sip show peers\r\n” );
to
fputs($socket, “Channel: sip show peers\r\n\r\n” );

I can’t imagine that the Command action uses a Channel parameter, nor can I imagine that a Channel parameter would contain anything other than a channel name or technology/address string.

Also, the read of the response from the Login doesn’t seem to be looking for the double newline.