In article <[EMAIL PROTECTED]>,
Vincent <[EMAIL PROTECTED]> wrote:
> On Mon, 12 Nov 2007 09:58:50 +0000 (UTC), [EMAIL PROTECTED]
> (Tony Mountifield) wrote:
> >I'm a little surprised at the variety of band-aid suggestions that have
> >been posted. All you need to do is refer to "show application record",
> >and you uwill see that the generated filename is available by using
> >${RECORDED_FILE}
>
> Thanks for the tip. The reason I was looking for another solution is
> that I couldn't get the value of the variable... but it's working now.
> I'm not comfortable yet with functions/applications, and have no idea
> what I did wrong :-/
>
> BTW, what's the difference between functions and applications?
An application is a "command" executed by a dialplan priority, such as
Record, Verbose, TrySystem, etc. in your example below.
A function needs to be evaluated inside ${ } and returns a string value
that is substitued in place of the ${ }, such as STRFTIME in your
second example.
> For those interested, here's some working code:
>
> ======
> exten => 555,1,Record(/tmp/msg%d.wav,3,30)
> exten => 555,n,Verbose(${RECORDED_FILE})
> exten => 555,n,TrySystem(mv ${RECORDED_FILE}.wav /var/www/asterisk/)
The above line might be dangerous. The way %d works is that Record
tries %d=1, then 2 and so on, until it finds a value that doesn't
already exist.
If you have, say, foo%d as the filename, it creates foo1.wav, but then
when you move foo1.wav to a different directory, Record will use foo1.wav
again the next time.
You can avoid that by using ln instead of mv, but when you want to
delete the file, you must remember to do so in both places.
Or you could symlink one directory to another.
> exten => 555,n,ExecIf($[${SYSTEMSTATUS} != SUCCESS],Verbose,Failed
> moving WAV file)
> ======
>
> Another way to generate a filename dynamically, using the current date
> + time:
> ======
> exten =>
> _[1-4],n,Set(CALLTIME=${STRFTIME(${EPOCH},GMT+1,%d-%b-%Y-%Hh%M)})
> exten => _[1-4],n,Record(/tmp/${CALLTIME}.wav,3,30)
> exten => _[1-4],n,TrySystem(mv /tmp/${CALLTIME}.wav
> /var/www/asterisk/)
> exten => _[1-4],n,ExecIf($[ ${SYSTEMSTATUS} != SUCCESS
> ],Verbose,Failed moving WAV file)
> ======
That certainly would avoid the problem of reusing the same %d, but would
break if you had two calls in the same second.
Cheers
Tony
--
Tony Mountifield
Work: [EMAIL PROTECTED] - http://www.softins.co.uk
Play: [EMAIL PROTECTED] - http://tony.mountifield.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users