Hello,
I’m trying to save a recorded message with the time/date stamp, upon hang up. I’ve got a shell script that is able to save the file, and to move it to the appropriate directory from the command line. But, I can’t seem to get Asterisk to execute the script properly.
What am I missing? I’ve tried both SHELL and System…and System(/var/spool/asterisk/tmp/./empty.sh | /var/spool/asterisk/tmp/newFile.gsm). Permission as correct on tmp file, and the depo file for Asterisk.
Am I passing the argument incorrectly? I’ve tried it with the |, and with the full path for the argument (/var/spool/asterisk/tmp/empty.sh /var/spool/asterisk/tmp/newFile.gsm).
Dialplan —>
exten => 1, 1, Set(step2count=0) ; —> Leave to msgs
same => n(toLeave), Playback(/usr/share/asterisk/sounds/en/dp_leaveMsg)
same => n(record), Record(/var/spool/asterisk/tmp/newFile.gsm)
exten => h,1,System(/var/spool/asterisk/tmp/empty.sh newFile.gsm) ;
same => n, Verbose(This was a ${SYSTEMSTATUS})
The script ---->
#!/bin/bash
_file="$1"
[ $# -eq 0 ] && { echo “Usage: $0 filename”; exit 1; }
[ ! -f “$_file” ] && { echo “Error: $0 file not found.”; exit 2; }
if [ -s “$_file” ]
then
echo “$_file has some data.”
# do something as file has data
TIMESTAMP=$(date +%m%d%y%H%M%S)
mv newFile.gsm /usr/share/asterisk/sounds/depo/$(date +%m%d-%H%M-%S).gsm
else
echo “$_file is empty.”
# do something as file is empty
fi