Execute an Asterisk System command

743 views
Skip to first unread message

newco

unread,
Feb 6, 2008, 9:28:57 AM2/6/08
to Adhearsion
Hello

I want to download some files from within Adhearsion.

In a 'normal' Asterisk dial plan something like this works:
exten => 865,3,System(/usr/bin/curl -s http://www.mysite.com/test2.gsm
> /var/tmp/test3.gsm)

I have tried the 'execute' command in Adhearsion, but that does not
seem to work:
Execute("System", "/usr/bin/curl -s http://www.mysite.com/test2.gsm
> /var/tmp/test3.gsm")

Any suggestions??

Philippe

Jay Phillips

unread,
Feb 6, 2008, 2:22:40 PM2/6/08
to adhea...@googlegroups.com
Hi Philippe,

A couple of ideas:

1. You could run Adhearsion on the same machine as Asterisk and just
pull down the file in Ruby-land. I don't recommend this for machines
already loaded down with the task of running Asterisk.

2. You could shell out in Adhearsion to ssh which executes wget on the
server. You'd need to copy over your SSH key to the Asterisk machine
first so that ssh can login without credentials. The line of code
would look like this:

`ssh 192.168.1.5 wget http://jicksta.com/foobar.gsm`

The backticks around the command in Ruby shells out and executes it.

In case you didn't know that ssh trick, if you add a command after the
connection information, ssh will connect, execute that command, and
then exit.

3. You could create a very tiny Ruby daemon to run on the Asterisk
machine. You'd create a helper in Adhearsion that sends commands to it
over DRb (distributed Ruby) instructing it to fetch a file.

Also, I notice in your email that you capitalized the execute()
method. Are you sure you didn't do this in your code? That'd
*definitely* not work :)

Jay Phillips

newco

unread,
Feb 6, 2008, 3:17:27 PM2/6/08
to Adhearsion
Jay

Thanks for the suggestions.
BTW, I checked ... I did not capitalize 'execute()' in the code; I did
not notice it in the email ;-(

Philippe

On Feb 6, 8:22 pm, Jay Phillips <jick...@gmail.com> wrote:
> Hi Philippe,
>
> A couple of ideas:
>
> 1. You could run Adhearsion on the same machine as Asterisk and just
> pull down the file in Ruby-land. I don't recommend this for machines
> already loaded down with the task of running Asterisk.
>
> 2. You could shell out in Adhearsion to ssh which executes wget on the
> server. You'd need to copy over your SSH key to the Asterisk machine
> first so that ssh can login without credentials. The line of code
> would look like this:
>
> `ssh 192.168.1.5 wgethttp://jicksta.com/foobar.gsm`
>
> The backticks around the command in Ruby shells out and executes it.
>
> In case you didn't know that ssh trick, if you add a command after the
> connection information, ssh will connect, execute that command, and
> then exit.
>
> 3. You could create a very tiny Ruby daemon to run on the Asterisk
> machine. You'd create a helper in Adhearsion that sends commands to it
> over DRb (distributed Ruby) instructing it to fetch a file.
>
> Also, I notice in your email that you capitalized the execute()
> method. Are you sure you didn't do this in your code? That'd
> *definitely* not work :)
>
> Jay Phillips
>
> On Feb 6, 2008, at 6:28 AM, newco wrote:
>
>
>
> > Hello
>
> > I want to download some files from within Adhearsion.
>
> > In a 'normal' Asterisk dial plan something like this works:
> > exten => 865,3,System(/usr/bin/curl -shttp://www.mysite.com/test2.gsm
> >> /var/tmp/test3.gsm)
>
> > I have tried the 'execute' command in Adhearsion, but that does not
> > seem to work:
> > Execute("System", "/usr/bin/curl -shttp://www.mysite.com/test2.gsm
Reply all
Reply to author
Forward
0 new messages