[App_rpt-users] dtmf to script not working for me.
Bryan Fields
Bryan at bryanfields.net
Thu Oct 25 11:55:58 UTC 2018
On 10/24/18 7:44 AM, edbathgate at zoominternet.net wrote:
> This simple script prints 1234, prints the time/date and appends the time and date onto file asd.dat.
>
> /etc/asterisk$ cat script: ab.sh
>
> #!/bin/bash
> echo 1234
> date
> date >> asd.dat
You are missing an absolute path for the asd.dat file you're writing to.
Lacking this, the script will run with the working directory of the parent
process when run from asterisk via DTMF. When run from the cli it will use
your shells current working directory.
> Script runs as it should from the command line of a linux console window
> /etc/asterisk$ ./ab.sh
> 1234
> Mon Oct 22 22:05:22 EDT 2018
> * Note the time ^^^
>
> Now to check the file and find 05:22: cat asd.dat
>
> Mon Oct 22 22:05:05 EDT 2018
> Mon Oct 22 22:05:22 EDT 2018 <yay it worked
> But from within Asterisk CLI it only works 1/2 way:
> *CLI> !/etc/asterisk/ab.sh
> 1234
> Mon Oct 22 22:11:44 EDT 2018
> * Note the time ^^^ 6 minutes later, It printed within the asterisk CLI, but did not append to the file.
It did append to a file, just not that file!
I bet you will have a file /asd.dat now. If you find the PID of the asterisk
process, you can look under /proc/$PID/cwd and that's a symlink to the current
working directory of the asterisk process.
> 714 = cmd,/etc/asterisk/ab.sh
This is working, just fine I might add. Your issue is the bash script you're
running (and generally it runs as root) needs an absolute path.
Fix that path and let us know if it works.
73s
--
Bryan Fields
727-409-1194 - Voice
http://bryanfields.net
More information about the App_rpt-users
mailing list