Don't save empty recordings

I assume you aren’t using FastAGI for the fast part, as shelling is the sort of thing that is avoided to make it fast, but rather because it is running on a different machine, so can’t directly access the file.

The only thing that will cause a dialplan variable or function to be dereferenced, in this context, is get variable. Note that this will only do one level of dereferncing.

The normal dereferencing is done when the dialiplan line is fetched, not when the application is running.

I don’t understand this. When I hear ‘dereferencing’ I think of using the dereference operator on a pointer to variable like in C. In Asterisk, I think of ‘evaluating’ a variable, but if I apply that to your sentence, I would interpret it as saying that variables are evaluated when the dialplan is parsed, not when it is executed, which would be incorrect. Can you clarify your meaning?

Dereferencing might be loose. Asterisks variables and functions are actually processed as text macros. When a dialplan line has been matched, at run time, a complete macro expansion (which I think includes the application name - although I thought wrong, see below) is performed, before the application name is examined. It is then parsed into application name and data, and the selected application is run with the fully expanded data.

When you use EXEC from AGI, I think that the application and data are already parsed out. In any case no macro expansion is performed.

When you use get variable, a single variable or function is substituted.

See the answers above

Maybe another set of eyes on the output would help.

Please post the output for the following. No pictures, no retyping, just cut 'n paste and wrapped in preformatted text tags to protect the innocent :slight_smile:

  1. Asterisk console output for a call demonstrating the issue with debug bumped up, verbose bumped up, and AGI debugging enabled.

  2. Shell output from executing the sox command without the awk command.

  3. A snippet of the code of your AGI that issues the AGI command.

Maybe we’re just expecting too much from FastAGI/exec/set or barking up the wrong tree. How about if in your FastAGI script, you:

  1. Retrieve the file name as a channel variable.
  2. Execute ‘system(“sox…|awk…”)’
  3. Delete the file if it doesn’t pass your thresholds for a ‘keeper.’
  4. Return the output/status of system() in a channel variable.

In case it is not clear, my suggestion (which assumes that ) the above is not possible because the AGI isn’t running on the same machine, is to retrieve the SHELL functin execution as though it were a channel variable.

Interesting thought, though I can’t think where this would have been useful :slight_smile:

Unfortunately:

; application as variable
        same = n,                       set(app=playback)
        same = n,                       verbose(app = ${app})
        same = n,                       ${app}(demo-congrats)
        same = n,                       hangup()

yields:

    -- Executing [*@newline:6] Set("SIP/poly-77a1-00000021", "app=playback") in new stack
    -- Executing [*@newline:7] Verbose("SIP/poly-77a1-00000021", "app = playback") in new stack
app = playback
[Nov  8 12:02:28] WARNING[5225][C-00000021]: pbx.c:2864 pbx_extension_helper: No application '${app}(demo-congrats)' for extension (newline, *, 8)
  == Spawn extension (newline, *, 8) exited non-zero on 'SIP/poly-77a1-00000021'

I did get to work now the SHELL function with get full variable and the SET function but i am stuck now at the printf part

Ok i got it to work this is the command:
GetFullVariable("${SET(ci=${SHELL(sox filename.wav -n stat 2>&1 | awk '/Maximum amplitude:/ {printf $3 * 1000000}')})}")

I wasn’t aware of their being a get full variable, as well as a get variable. However, it seems overkill in this case, unless you really need the a real channel variable setting.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.