[OpenSIPS-Users] How can I write down the MI commands into the FIFO file, using an editor.

Ionut Muntean ionutm22 at gmail.com
Wed Dec 2 18:09:06 CET 2015


Rodrigo,

First of all, sorry for my last response. I was out of line. Appologies.

A FIFO file is a pipe, not a regular file. You cannot edit it like a 
normal text file with vi, for instance. A FIFO is a special inode that 
transports data between a live process and the standart input. You can 
paste with "echo" lots of data into the FIFO file and the data will get 
to the running process in the FIFO way, first data in - first data out 
(to the process).

If the process creating the FIFO file is run by root, you must be root 
that is sending the data to the file. If the process that is creating 
the FIFO file is not running, the file should not be left in the 
filesystem. So, if you try to edit (sic!) the file, while the creating 
process is not running, you will get something like "file not found", or 
if you are trying to send data into the file as user rodrigo while the 
process is running as user root, you will get an error.

I made an PHP script for my purpose, that is sending commands to my 
Opensips FIFO file and reading the result of that. The script is run by 
the same user as Opensips. If I try to run the script while Opensips is 
not running, the error always could be as "file not found".

If you are writing an C progam to send commands to the opensips FIFO 
file, first of all make sure you are running your program as the sam 
user as the Opensips. Second, make sure that Opensips is running. Then 
write and read results from that file in your C program.

All the best,
M.Ionut

On 02/12/2015 18:47, Liviu Chircu wrote:
> Hi Rodrigo,
>
> Most likely you're starting opensips as root user, however you're 
> attempting to write to the FIFO file on behalf of an unprivileged user.
>
> So either do "sudo echo_to_file_command" or just start OpenSIPS in 
> unprivileged mode.
>
> Here's my FIFO file, I can write to it:
>
> [liviu ◄ Rivendell ~]$ ls -la /tmp/opensips_fifo
> prw------- 1 liviu liviu 0 dec  2 11:02 /tmp/opensips_fifo
>
>
> BR,
> Liviu Chircu
> OpenSIPS Developer
> http://www.opensips-solutions.com
> On 02.12.2015 12:53, Rodrigo Pimenta Carvalho wrote:
>>
>> Ok. thanks.
>>
>>
>> I will search about it in operational system context. I used to think 
>> that such fifo file was 100% supported by OpenSIPS. I didn't realize 
>> that it could be something of unix.
>>
>>
>> I'm kind of a beginner in unix or linux.
>>
>>
>> Regards.
>>
>>
>> RODRIGO PIMENTA CARVALHO
>> Inatel Competence Center
>> Software
>> Ph: +55 35 3471 9200 RAMAL 979
>>
>>
>> ------------------------------------------------------------------------
>> *De:* users-bounces at lists.opensips.org 
>> <users-bounces at lists.opensips.org> em nome de Ionut Muntean 
>> <ionutm22 at gmail.com>
>> *Enviado:* terça-feira, 1 de dezembro de 2015 17:19
>> *Para:* users at lists.opensips.org
>> *Assunto:* Re: [OpenSIPS-Users] How can I write down the MI commands 
>> into the FIFO file, using an editor.
>> Come on, read about FIFO in Linux, lot's of info on the net! Sorry, 
>> but you lack some basic Linux OS knowledge ... The FIFO is active and 
>> RW if the creating process is active and if you have the permissions 
>> to do this.
>>
>> On 01/12/2015 21:13, Rodrigo Pimenta Carvalho wrote:
>>>
>>> Ok. Thanks.
>>>
>>>
>>> But, if I cann't edit the file, how could a program (let's say a C 
>>> program) write into such file?
>>>
>>>
>>> I will create a executable that will have to write down MI commands 
>>> into the FIFO file.
>>>
>>>
>>> Any hint will be very helpful!
>>>
>>> Thanks a lot!
>>>
>>>
>>> RODRIGO PIMENTA CARVALHO
>>> Inatel Competence Center
>>> Software
>>> Ph: +55 35 3471 9200 RAMAL 979
>>>
>>>
>>> ------------------------------------------------------------------------
>>> *De:* users-bounces at lists.opensips.org 
>>> <users-bounces at lists.opensips.org> em nome de Brian :: <bc at iptel.co>
>>> *Enviado:* terça-feira, 1 de dezembro de 2015 16:38
>>> *Para:* OpenSIPS users mailling list
>>> *Assunto:* Re: [OpenSIPS-Users] How can I write down the MI commands 
>>> into the FIFO file, using an editor.
>>> This is not the correct way to go about what you are trying to achieve.
>>>
>>> You *cant* edit the fifo file. You use (correctly configured) 
>>> opensipsctl fifo to send commands in realtime
>>>
>>> On Tue, Dec 1, 2015 at 5:04 PM, Rodrigo Pimenta Carvalho 
>>> <pimenta at inatel.br <mailto:pimenta at inatel.br>> wrote:
>>>
>>>     Dear OpenSIPS-users,
>>>
>>>
>>>     I my opensips.cfg I have:
>>>
>>>
>>>     ---------------------------------------------------------
>>>
>>>
>>>     ##### FIFO Management Interface
>>>     loadmodule "mi_fifo.so"
>>>     modparam("mi_fifo", "fifo_name", "/tmp/FifoCommands.txt")    #
>>>     arquivo para ler comandos solicitados por aplicações externas.
>>>     modparam("mi_fifo", "reply_dir", "/tmp")                     #
>>>     diretório onde serão escritas as respostas do OpenSIPS, que
>>>     serão lidas pelas aplicações externas.
>>>     modparam("mi_fifo", "fifo_mode", 0777)                       #
>>>     permissão de scrita e leitura.
>>>     modparam("mi_fifo", "fifo_group", "root")                    #
>>>     grupo de usuários para o arquivo.
>>>     modparam("mi_fifo", "fifo_user", "root")                     #
>>>     usuário do arquivo.
>>>
>>>
>>>     ----------------------------------------------------------
>>>
>>>
>>>
>>>     When OpenSIPS is not running, I can edit the file
>>>     FifoCommands.txt using emacs or vi, for example.
>>>
>>>
>>>     However, when OpenSIPS is running I can not.  The editor tells
>>>     me that the file is read only Why? How to solve this? Any
>>>     configuration?
>>>
>>>
>>>     Any hint will be very helpful!
>>>
>>>
>>>     Thanks a lot.
>>>
>>>
>>>
>>>
>>>
>>>     RODRIGO PIMENTA CARVALHO
>>>     Inatel Competence Center
>>>     Software
>>>     Ph: +55 35 3471 9200 <tel:%2B55%2035%203471%209200> RAMAL 979
>>>
>>>     _______________________________________________
>>>     Users mailing list
>>>     Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>>>     http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
>
> _______________________________________________
> 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/20151202/327cf1c0/attachment.htm>


More information about the Users mailing list