[asterisk-users] System() command refuses to execute bash script

Tech Support asterisk at voipbusiness.us
Mon Mar 2 10:15:26 CST 2015


I'm surprised that you didn't have to specify the full path to the 'touch'
command. When writing AGI scripts, I always do something like 
$touch = which( 'touch' ). I guess it's over kill.
John

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Stefan Viljoen
Sent: Monday, March 02, 2015 9:45 AM
To: asterisk-users at lists.digium.com
Subject: Re: [asterisk-users] System() command refuses to execute bash
script

Hi all

I got this solved.

Turns out the script WAS executing, but I forgot that apparently you need to
follow "cron rules" in any BASH scripts executed via System() from an
Asterisk dialplan.

E. g. all paths must be fully and absolutely specified, there are no
relative path references available.

So I changed the the file wireless.sh which was:

#!/bin/bash
touch wireless-executed

to

#!/bin/bash
touch /root/wireless-executed

and now if I phone 800 on my Asterisk context I can see that the file 

wireless-executed

is created by the touch binary, which indicates that Asterisk has run the
script successfully.

So the problem was not Asterisk or BASH or permissions, but rather that it
appears that all paths in any System() script must be absolutely, not
relatively, specified.

Hope this helps somebody - simply follow "cron rules" when writing
Asterisk-callable BASH scripts which you plan to trigger via the System()
Asterisk dialplan application.

Regards

Stefan


--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to
Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list