[OpenSIPS-Users] Any official instructions how to use the MI commands?
Răzvan Crainea
razvan at opensips.org
Wed Apr 18 00:02:46 CEST 2012
Hi, Xi!
In order to use the MI fifo, you should first take a look at the module
documentation[1]. You have there an example[2] of how a request should
be built, and also the syntax grammar[3].
Just out of curiosity, why don't you use directly the opensipsctl tool?
[1] http://www.opensips.org/html/docs/modules/devel/mi_fifo.html
[2] http://www.opensips.org/html/docs/modules/devel/mi_fifo.html#id250088
[3] http://www.opensips.org/html/docs/modules/devel/mi_fifo.html#id248321
Regards,
Răzvan
On 04/17/2012 11:31 PM, Xi Liu wrote:
> Hi All,
>
> I'm trying to find the official documentation about how to use MI interface with named pipe, while I searched all over the web but can't find any...
>
> Though I found an example in the list and able to repeat it, but still have two questions,
>
> 1, How can I pass parameters along with the command? Currently I can run those functions that does not require parameters, e.g. address_dump, uptime.
> But I would like to use ul_add, ul_show_contact, etc.
>
> 2, I wrote a perl code which expected to read out put from opensips which for some reason never worked. When I wrote the perl code I took /example/web_MI/*.php as examples..
>
> Any help would be appreciated!
>
> ================
>
> Example I found,
>
> mkfifo /tmp/my_fifo
> cat /tmp/my_fifo&
> echo -e ":address_dump:my_fifo\n\n"> /tmp/opensips_fifo
> *returns*
> 200 OK
> 48<1.2.3.4,2, 0, 0, NULL, NULL>
> ** cat process ends
>
> ================
>
> Perl code I wrote,
>
> #!/usr/bin/perl
>
> use strict;
>
> # Initial values
> my $os_fifo="/tmp/opensips_fifo";
> # Open OS fifo and wait for cmd
> open OSFIFO, $os_fifo or die "Can't open opensips fifo: ".$os_fifo;
>
> # open reply fifo
> my $fifo_reply_filename = "fifo_".int(rand(100));
> my $fifo_path = "/tmp/".$fifo_reply_filename;
> system("mkfifo -m 666 ".$fifo_path);
>
> # fifo cmd
> my $fifo_cmd = ":uptime:".$fifo_path."\n\n";
>
> # execute fifo cmd
> print OSFIFO $fifo_cmd;
>
> close OSFIFO;
>
> # Read output
> open FIFO, $fifo_path or die "Can't open fifo: ".$fifo_path;
>
> my $line_num = 1;
>
> while (<FIFO>) {
> print "line $line_num: ".$_;
> $line_num++;
> }
>
> close FIFO;
>
> unlink $fifo_path;
>
> ================
>
> Thanks,
> Xi
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120418/20dce717/attachment-0001.htm>
More information about the Users
mailing list