Using ExecIF and STAT in a dialplan

Hi, this is what I want to do. If a voicemail .wav file is 44 bytes, I want to delete the .wav file, the .txt file, and the corresponding .WAV file. I’ve been trying variations of:

exten => exit-SUCCESS,n,ExecIf(STAT(s,${VM_MESSAGEFILE}.wav)=44,System(rm ${VM_MESSAGEFILE}.WAV))

In the CLI it gets interpreted as:

"STAT(s|/var/spool/asterisk/voicemail/default/70312/INBOX/msg0054.wav)=44|System(rm /var/spool/asterisk/voicemail/default/70312/INBOX/msg0054.WAV)")

but it’s never deleting any files. What do I need to write to achieve what I want?

I’m using Asterisk 1.4

Thanks in advance.

Function calls need to be in ${}

OK, I apologize, I guess I’m not completely understanding the syntax. I changed the line to:

exten => exit-SUCCESS,n,ExecIf(${STAT(s,${VM_MESSAGEFILE}.wav)}=44,System(rm ${VM_MESSAGEFILE}.WAV))

and it got interpreted in the CLI as:

So it’s closer (the 44=44 is encouraging) but the WAV file still isn’t getting deleted. Do I need to enclose the System in ${}?

Should it be:

Thanks.

You need to enclose the expression in $[]. The boolean will collapse to just 0 or 1, in the CLI output, when you have it correct.

The system doesn’t need ${}, but according to The Book, its arguments should be given as arguments of ExecIf. Not tested, but I think you want:

Got it. I tested it, and that worked perfectly!

Thanks a lot for all the help!!