[asterisk-dev] Module to Asterisk function Compiler Issue question

Tzafrir Cohen tzafrir.cohen at xorcom.com
Sun Aug 7 23:48:18 CDT 2011


On Sun, Aug 07, 2011 at 07:20:10PM -0700, Mike Myhre wrote:
>
>> It's doing exactly what the exec() family of functions is supposed to
>> do; replace the current executable image in the process with a
>> different one and then execute it. If you want to execute the shell
>> script in a child process, you have to fork() first... but you'd be
>> better off to use ast_safe_system() which handles quite a few other
>> nasty details for you as well.
> I have one more question on the ast_safe_system() function and child  
> processes. Is there a simple way to get output from a shell script? My  
> CLI command has an open file descriptor I want to write to (a->fd) that  
> should be open in my child process. I tried passing the file descriptor  
> as a command argument and using it in a shell script, but I get the "Bad  
> file descriptor" message on stderr output. I could write to a temporary  
> file and read the file from my res module, but that isn't a very clean  
> solution.
>
> Is there a preferred way to get output from shell scripts to the  
> asterisk CLI?

As you can see in the source of dialplan function SHELL
(funcs/func_shell.c), it just uses popen(3).

-- 
               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



More information about the asterisk-dev mailing list