virendra bhati
2011-Sep-02 11:28 UTC
[asterisk-users] how to add-edit-delete entery into asterisk conf files
Hi list, I want ot do basic work (add-edit-delete) into asterisk configuration files, like sip.conf, manager.conf,musiconhold.conf etc. Please guide me how to configure all these files from from AMI connection. I am able to login into AMI from Login action but I want to do more task in to it. *AMI login:- * *login.php* <?php $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30); fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: root\r\n"); fputs($socket, "Secret: energy\r\n\r\n"); ?> *AMI command:-* Below commands are for musiconhold.conf. I want to add new MOH context into it. <?php include("login.php"); fputs($socket, "Action: UpdateConfig\r\n"); fputs($socket, "Filename: musiconhold.conf\r\n"); fputs($socket, "Srcfilename: musiconhold.conf\r\n"); fputs($socket, "Dstfilename: musiconhold.conf\r\n"); fputs($socket, "Action-000000: newcat\r\n"); fputs($socket, "Cat-000000: bhavik\r\n"); fputs($socket, "mode: files\r\n"); fputs($socket, "directory: /var/lib/asterisk/moh\r\n"); fputs($socket, "Reload: yes\r\n"); fputs($socket, "ActionID: 9873497149817\r\n"); fputs($socket, "Action: Logoff\r\n\r\n"); ?> After doing all no success :(( ----- Thanks and regards Virendra Bhati +91-9172341457 Software Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110902/965fcc13/attachment.htm>
C F
2011-Sep-02 19:23 UTC
[asterisk-users] how to add-edit-delete entery into asterisk conf files
Why php? Isn't vi the only way? On Fri, Sep 2, 2011 at 7:28 AM, virendra bhati <virbhati at gmail.com> wrote:> Hi list, > > I want ot do basic work (add-edit-delete) into asterisk configuration files, > like sip.conf, manager.conf,musiconhold.conf etc. > > Please guide me how to configure all these files from from AMI connection. I > am able to login into AMI from Login action but I want to do more task in to > it. > > AMI login:- > > login.php > > <?php > $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30); > fputs($socket, "Action: Login\r\n"); > fputs($socket, "UserName: root\r\n"); > fputs($socket, "Secret: energy\r\n\r\n"); > ?> > AMI command:- > > Below commands are for musiconhold.conf. I want to add new MOH context into > it. > <?php > include("login.php"); > ? fputs($socket, "Action: UpdateConfig\r\n"); > ? fputs($socket, "Filename: musiconhold.conf\r\n"); > ? fputs($socket, "Srcfilename: musiconhold.conf\r\n"); > ? fputs($socket, "Dstfilename: musiconhold.conf\r\n"); > ? fputs($socket, "Action-000000: newcat\r\n"); > ? fputs($socket, "Cat-000000: bhavik\r\n"); > ? fputs($socket, "mode: files\r\n"); > ? fputs($socket, "directory: /var/lib/asterisk/moh\r\n"); > ? fputs($socket, "Reload: yes\r\n"); > ? fputs($socket, "ActionID: 9873497149817\r\n"); > ? fputs($socket, "Action: Logoff\r\n\r\n"); > > ?> > > After doing all no success :(( > > > ----- > Thanks and regards > > ?Virendra Bhati > +91-9172341457 > Software Engineer > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > ? ? ? ? ? ? ? http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > ? http://lists.digium.com/mailman/listinfo/asterisk-users >
Daniel Tryba
2011-Sep-03 11:48 UTC
[asterisk-users] how to add-edit-delete entery into asterisk conf files
On Fri, Sep 02, 2011 at 04:58:52PM +0530, virendra bhati wrote:> Please guide me how to configure all these files from from AMI connection. I > am able to login into AMI from Login action but I want to do more task in to > it.[lots of fputs]> After doing all no success :((Have you actually tried reading from the socket to see what the results are for your commands (hint: turn off events)? This is what I get: Response: Success ActionID: 9873497149817 Looking at http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+UpdateConfig it is clear that adding values to a category works different than you expected. First you need to create the new category (your scripts does that already), then you need to append lines to is in the form of appends to the category like in the example on voip-info.org: action:updateconfig reload:yes srcfilename:manager.conf dstfilename:manager.conf Action-000000:append Cat-000000:newuser Var-000000:secret Value-000000:nottelling -- Daniel Tryba
virendra bhati
2011-Sep-03 12:38 UTC
[asterisk-users] how to add-edit-delete entery into asterisk conf files
Hi Raza, Thanks , but there is no ned of Sip.conf and extensions.conf files. As Daniel refered the web page which is enough for all the tasks On Sat, Sep 3, 2011 at 5:18 PM, Daniel Tryba <daniel at tryba.nl> wrote:> On Fri, Sep 02, 2011 at 04:58:52PM +0530, virendra bhati wrote: > > Please guide me how to configure all these files from from AMI > connection. I > > am able to login into AMI from Login action but I want to do more task in > to > > it. > [lots of fputs] > > After doing all no success :(( > > Have you actually tried reading from the socket to see what the results > are for your commands (hint: turn off events)? > > This is what I get: > Response: Success > ActionID: 9873497149817 > > Looking at > http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+UpdateConfig > it is clear that adding values to a category works different than you > expected. > > First you need to create the new category (your scripts does that > already), then you need to append lines to is in the form of appends to > the category like in the example on voip-info.org: > > action:updateconfig > reload:yes > srcfilename:manager.conf > dstfilename:manager.conf > Action-000000:append > Cat-000000:newuser > Var-000000:secret > Value-000000:nottelling > > -- > > Daniel Tryba > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- ----- Thanks and regards Virendra Bhati +91-9172341457 Software Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110903/cd08bbaa/attachment.htm>
Zohair Raza
2011-Sep-03 12:41 UTC
[asterisk-users] how to add-edit-delete entery into asterisk conf files
ok. Thanks On Sat, Sep 3, 2011 at 5:38 PM, virendra bhati <virbhati at gmail.com> wrote:> Hi Raza, > > Thanks , but there is no ned of Sip.conf and extensions.conf files. > As Daniel refered the web page which is enough for all the tasks > > > > On Sat, Sep 3, 2011 at 5:18 PM, Daniel Tryba <daniel at tryba.nl> wrote: > >> On Fri, Sep 02, 2011 at 04:58:52PM +0530, virendra bhati wrote: >> > Please guide me how to configure all these files from from AMI >> connection. I >> > am able to login into AMI from Login action but I want to do more task >> in to >> > it. >> [lots of fputs] >> > After doing all no success :(( >> >> Have you actually tried reading from the socket to see what the results >> are for your commands (hint: turn off events)? >> >> This is what I get: >> Response: Success >> ActionID: 9873497149817 >> >> Looking at >> >> http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+UpdateConfig >> it is clear that adding values to a category works different than you >> expected. >> >> First you need to create the new category (your scripts does that >> already), then you need to append lines to is in the form of appends to >> the category like in the example on voip-info.org: >> >> action:updateconfig >> reload:yes >> srcfilename:manager.conf >> dstfilename:manager.conf >> Action-000000:append >> Cat-000000:newuser >> Var-000000:secret >> Value-000000:nottelling >> >> -- >> >> Daniel Tryba >> >> -- >> _____________________________________________________________________ >> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >> New to Asterisk? Join us for a live introductory webinar every Thurs: >> http://www.asterisk.org/hello >> >> asterisk-users mailing list >> To UNSUBSCRIBE or update options visit: >> http://lists.digium.com/mailman/listinfo/asterisk-users >> > > > > -- > > > > ----- > Thanks and regards > > Virendra Bhati > +91-9172341457 > Software Engineer > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- Regards, Zohair Raza www.zuhair.info *http://pk.linkedin.com/in/zuhairraza** *** -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110903/4b57e14a/attachment.htm>
Tzafrir Cohen
2011-Sep-04 13:00 UTC
[asterisk-users] how to add-edit-delete entery into asterisk conf files
On Fri, Sep 02, 2011 at 04:58:52PM +0530, virendra bhati wrote:> Hi list, > > I want ot do basic work (add-edit-delete) into asterisk configuration files, > like sip.conf, manager.conf,musiconhold.conf etc. > > Please guide me how to configure all these files from from AMI connection. I > am able to login into AMI from Login action but I want to do more task in to > it. > > *AMI login:- * > > *login.php* > > <?php > $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30); > fputs($socket, "Action: Login\r\n"); > fputs($socket, "UserName: root\r\n"); > fputs($socket, "Secret: energy\r\n\r\n"); > ?> > *AMI command:-* > > Below commands are for musiconhold.conf. I want to add new MOH context into > it. > <?php > include("login.php"); > fputs($socket, "Action: UpdateConfig\r\n"); > fputs($socket, "Filename: musiconhold.conf\r\n"); > fputs($socket, "Srcfilename: musiconhold.conf\r\n"); > fputs($socket, "Dstfilename: musiconhold.conf\r\n"); > fputs($socket, "Action-000000: newcat\r\n"); > fputs($socket, "Cat-000000: bhavik\r\n"); > fputs($socket, "mode: files\r\n"); > fputs($socket, "directory: /var/lib/asterisk/moh\r\n"); > fputs($socket, "Reload: yes\r\n"); > fputs($socket, "ActionID: 9873497149817\r\n"); > fputs($socket, "Action: Logoff\r\n\r\n");You're not really editing. You're writing. Note the following: * It requires Asterisk to be running, and accessible through the manager interface. * asterisk.conf may be in a path that is not the configuration directory. I'm not sure if this special case is handled. * #include are basically handled, but mostly for reading. IIRC the write is back to a single file. No idea about #exec, which will probably have odd interactions with UpdateConfig. Configuration templates ('[section](template)') are also not handled gracefully.> > After doing all no success :((This is a report of the the thing that did not happen. Next time you ask a question, please report what actually does happen ("I got the following response: ..."). -- Tzafrir Cohen icq#16849755 jabber:tzafrir.cohen at xorcom.com +972-50-7952406 mailto:tzafrir.cohen at xorcom.com http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir