开发者

Bash script in agi-bin fails to execute - asterisk

I am trying to execute a bash script from within my dialplan. The bash scripts are from within a directory projectFiles in /var/lib/asterisk/agi-bin. When I try to execute the script, like so:

exten => 0,n,System(/var/lib/asterisk/agi-bin/projectFiles/main.sh ${RECORDED_FILE}.wav ${SOUND_PATH}/menus/wav2.wav)  

I end up with the following error:

WARNING[27515]: app_system.c:125 system_exec_helper: Unable to execute '/var/lib/asterisk/agi-bin/projectFiles/main.sh /tmp/rec62.wav /var/lib/asterisk/sounds/en/projects/menus/wav2.wav'
  == Spawn 开发者_Python百科extension (test-project, 0, 5) exited non-zero on 'DAHDI/15-1'   

The permissions to the script main.sh are set at asterisk as owner and group. Where might I be going wrong?

Any help is most welcome,

Sriram.


I had the same problem and found another reason, which might be common: I had created the script on Windows, and copied over in binary mode. The text file contained the hidden ^M at each line end. I removed all of them and everything is fine! The error message is of course extremely misleading!


The script within agi-bin, main.sh did not execute successfully. Hence the error message. One line within main.sh copied $1 of the input arguments to the present working directory, which I had assumed would be the same directory in which the script was placed. $HOME for asterisk (and from where it executes all scripts) is /etc. So, a line like the following:

cp $1 .

would copy $1 to /etc. This caused mayhem further down the script. Changing that line makes everything work OK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜