Save recorded msg on hangup with date/time stamp

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

I had the same problem and it is solved by adding Hangup() application.

Try

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 => n , Hangup()

No, that doesn’t seem to work either. This is what I have —>

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) ; to autosave on hangup = ,k

    same => n(action), Read(response,/usr/share/asterisk/sounds/en/dp_postLeaveMsg1, 1)
    same => n, GotoIf($["${response}" = "1"]?99,listen:)  ; --> go to listen, if like, save; if not, re-record
    same => n, GotoIf($["${response}" = "2"]?98,saveit:) ; ---> just go save it; leave another or listen to o$
    same => n, GotoIf($["${response}" = "3"]?1,record:) ; ---> go to record
    same => n, GotoIf($["${response}" = "4"]?2,1:)   ; ----> go to listen to vms
    same => n, WaitExten(5)
    same => n, Background(/usr/share/asterisk/sounds/en/dp_stillthere)
    same => n, Goto(action)
    same => n, Hangup()

exten => h,1,System(bash /var/spool/asterisk/tmp/empty.sh | /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})
;same => n, Hangup()

exten => i,1,Playback(db_invalid)
same => n, Goto(start,beginning)

exten => t,1,Playback(vm-goodbye)
same => n,Hangup()

This ended up working ----------->

exten => h,1,Set(result=${SHELL(bash /var/spool/asterisk/tmp/empty.sh)})
same => n,NoOp(result is ${result})
same => n, Hangup()

Shell script -------->

#!/bin/bash
cd /var/spool/asterisk/tmp
mv newFile.gsm /usr/share/asterisk/sounds/depo/$(date +%m%d-%H%M-%S).gsm