Hi, thanks for the replies. Here’s the full background on this and what I’m trying to do…
I’m using an open source PBX system called Asterisk, running on a Linux CentOS box. Asterisk uses a “dialplan” proprietary language to let you control what happens when someone makes a call. One of the commands is called Systemwhich lets you run a command line argument.
What I’m doing is using that function to call SoX (an open Source audio editor) to clean up voicemail messages that are left. I’m basically using SoX functions to delete silence and hangup clicks from the ends of the voicemail and amplify the files. In the code below, the variable ${VM_MESSAGEFILE} is the location on the server of the voicemail file. The lines of code I use are:
exten => exit-SUCCESS,n,System(sox ${VM_MESSAGEFILE}.wav ${VM_MESSAGEFILE}-old.wav)
exten => exit-SUCCESS,n,System(sox ${VM_MESSAGEFILE}-old.wav ${VM_MESSAGEFILE}.wav compand 0.3\,1 6:-70\,-60\,-20 -5 -90 0.2 vad reverse vad reverse)
exten => exit-SUCCESS,n,System(rm ${VM_MESSAGEFILE}-old.wav)
OK, great. The code works perfectly, but here’s the problem. Let’s say someone leaves a voicemail message of just silence. When SoX runs, it will delete out the silence but it leaves a stub of a WAV file. That file is always a certain fixed size (44 bytes to be exact) and I want to delete it because it is unplayable anyway. There are also ancillary files associated with that same message that I want to delete that have the same name, but different extensions, and I want to delete those documents as well.
So, the logic is kind of like, if msg0032.wav is 44 bytes, delete that file along with msg0032.WAV and msg0032.txt
The reason I was shying away from a shell script is that the variable ${VM_MESSAGEFILE} is coming from the asterisk pbx system, and I’m not sure if I can pass it to an external shell script.
I haven’t tested it yet, but it looks like friedo’s suggestion might work? Hopefully this all makes sense…