[asterisk-users] How to invoke an external C program and output an integer to the program?

johnny_xing johnny_xing at banshing.com
Wed Oct 15 22:22:32 CDT 2008


Hi,

I want to call an extension like 88888 and invoke an external C program upon
calling, pass an constant integer like 1 to the C program.

What I have done is:

/etc/extensions.conf:
exten => 88888,1,system(/usr/local/src/parallel/fire 1)
exten => 88888,n, Dial(SIP/88888)
exten => 88888,n,Hangup

the C program under /usr/local/src/parallel/fire will wait for the input, if
it's 1 external LED light will be on, if it's 0 LED light will be off.

I have changed the file ownership and group since my asterisk user is
asterisk (with freepbx):

[root at Fire-Station parallel]# ls -l fire*
-rwxrwxrwx  1 asterisk asterisk 5882 Oct 16 09:18 fire
-rw-rw-rw-  1 asterisk asterisk 2793 Oct 15 22:25 fire.c


If I run the program separately everything is fine:

[root at Fire-Station parallel]# /usr/local/src/parallel/fire 1
buffer is 1
input1 value is 1
open port successfully
Input1 is high, Pin 17 set to high
Input1 is 1
[root at Fire-Station parallel]# /usr/local/src/parallel/fire 0
buffer is 0
input1 value is 0
open port successfully
Input1 is low, Pin 17 set to low
Input1 is 0
[root at Fire-Station parallel]#

However if I call to 88888 I can see it execute the system command but it
doesn't output an integer 1 to my 'fire' program.

CLI:
-- Executing System("SIP/10-09a63138", "/usr/local/src/parallel/fire 1") in
new stack

Any ideas on this or I shouldn't use System() at all?

Thanks & Best Regards,
 
Johnny Xing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20081016/7ec06625/attachment.htm 


More information about the asterisk-users mailing list