using variables in the shell function

Home » Asterisk Users » using variables in the shell function
Asterisk Users 1 Comment

On Wed, 14 Sep 2011, Israel Gottlieb wrote:

> is it possible to pas variables to the shell function
>
> Set(recordingavail=${SHELL(“ls /var/lib/asterisk/sounds/custom/${TOPMENU}”)})
>
> im trying to see if a file is available before playing the file
>
> or does anybody have a different idea but not using agi

Why not AGI?

They both (‘shelling out’ or calling an AGI) have the same ‘impact’ on
system resources.

You can even write an AGI in shell if you lack the skills for other
languages like C, PHP, or Perl.

You should be able to cobble up an AGI in PHP (or Perl, but I’m not much
of a Perl coder myself) just by cutting and pasting from some of the
examples on voip-info.org.

This simple task would be a great way for you to ‘get your feet wet.’

What will you do if the file is not available?

One thought on - using variables in the shell function

  • You should check out the STAT function.

    core show function STAT

    This should evaluate to 1
    ${STAT(e,/var/lib/asterisk/sounds/en/vm-goodbye.gsm)})

    This should evaluate to 0
    ${STAT(e,/var/lib/asterisk/sounds/en/xyzzy.gsm)}

    Dale