Asterisk run external bash script

I am trying very hard to get Asterisk to execute an external bash script. What I am looking for is a simple script that calls vinagre to refresh a display.

I copied vinagre to vncopen so I can kill it and leave any other vinagre open and am trying to call it through a bash script.

vncopen (vinagre) does not run BUT the sleep command does work. It exits with a 0 and it doesnt work with AGI System TrySystem or others. What am I doing wrong? I hope to use this for alot of home automation type stuff but unless it will call a bash shell script I don’t know.

Here is the script, the extensions.conf portion and the output to the log file

/usr/local/bin/vncopen &
sleep 10
killall -KILL vncopen


exten => _*90,1,NoOp(Starting or attempting as such)
exten => _*90,2,AGI(/usr/local/bin/;System(/usr/local/bin/vncopen|
exten => _*90,3,Wait(3)
exten => _*90,4,NoOp();System(killall|-KILL|vncopen)
exten => _*90,5,Hangup

Log File

[Mar 11 20:17:00] VERBOSE[27328] logger.c: – Executing [*90@unlimited:1] NoOp(“SIP/200-09324128”, “Starting or attempting as such”) in new stack
[Mar 11 20:17:00] VERBOSE[27328] logger.c: – Executing [*90@unlimited:2] AGI(“SIP/200-09324128”, “/usr/local/bin/”) in new stack
[Mar 11 20:17:00] VERBOSE[27328] logger.c: – Launched AGI Script /usr/local/bin/
[Mar 11 20:17:10] VERBOSE[27328] logger.c: – AGI Script /usr/local/bin/ completed, returning 0
[Mar 11 20:17:10] VERBOSE[27328] logger.c: – Executing [*90@unlimited:3] Wait(“SIP/200-09324128”, “3”) in new stack
[Mar 11 20:17:13] VERBOSE[27328] logger.c: – Executing [*90@unlimited:4] NoOp(“SIP/200-09324128”, “”) in new stack
[Mar 11 20:17:13] VERBOSE[27328] logger.c: – Executing [*90@unlimited:5] Hangup(“SIP/200-09324128”, “”) in new stack
[Mar 11 20:17:13] VERBOSE[27328] logger.c: == Spawn extension (unlimited, *90, 5) exited non-zero on ‘SIP/200-09324128’

You can simply use the System application like:

exten => s,n,System(/var/lib/agi-bin/

Hope this helps

I already tried that.

none of them work.
could it be because I am calling a command that utilises the XWin components for graphical issues?
Cant get Mumble to work either the same way. I can get most command line scripts to work but I haven’t looked at alot of them. But anything that uses the Gnome or KDE GUI does not seem to work.

Reasons I can think of:

the ownership and permissions aren’t set well. The script should be executable and, if started with System() executable by the asterisk user.

chmod 777 <script_path><script_name> will do but is not so save (everybody can execute and change the script). For testing it seems to be a good idea.

If modus of the script is set to 777 it should run otherwise there is something wrong with the script. System() should run every script that can be run from the linux prompt regardless what it is actually doing.

If you run your Asterisk system with user Asterisk it is wise to set ownership of the script to Asterisk and permissions to 700 (change, write and execute by owner) Perhaps others have better advice (I’m not the permission expert) but I hope it helps