Run External Application

Trying to get asterisk to launch an app when exten is dialed…like this:

exten 999 then run /usr/bin/app.bat
(running on serve 2003…dont ask…)

Where I can make a bat script to then do what I want.

I see the system() an exec() but they appear to only send info back to the stdout not actually launch a separate program. Is there any way to get this accomplished?

Use AGI for that purpose.

yea yea, tried to write an agi script that opens a bat file but when the script runs the bat file doesn’t get executed. Im thinking it may be because its on server 2003 and cygroot cant execute it, but dont know. I i some googling and it appeared to me that agi only sends app information back to the asterisk stdin/out…am I wrong?

Is there anyong that can point to a simple agi script that will open a dos bat or perl script so I can get a feel for how its done?

I really appreciate it.

May be with this service it can easily

I will look into that… Here is basically all I want to accomplish… This perl works fine when I double click it… How do I get AGI or asterisk to run it, cuz the script runs ok, but nothing gets executed when asterisk has a go at it…

#!/usr/bin/perl
$ExecString = ‘C:\cygroot\usr\bin\tscon.cmd’;
exec $ExecString;

I know its probably a simple thing that I am not doing right, or some concept that I am missing here…

Hi

The system command wlll run it, But you need to make sure that the script can be run as teh user that asterisk is running as , more than likely asterisk and that the commands in the script are correctly defined.

Ian

Yea I have tried that, but I i it again just to be sure…

I set up test ext:

exten => 95,1,Answer
exten => 95,n,System(/usr/bin/tscon.pl)
exten => 95,n,AGI(agi-tscon2.agi)
exten => 95,n,Hangup

CLI says executing( blah blah…), but nothing happens…

verified permissions…

hi

I doubt the cli said [quote]blah blah…[/quote] it proberly reported something more meaingfull

so if you su to asterisk and then run the command usr/bin/tscon.pl the comand executes ?

lots of useful info here voip-info.org/wiki/view/Asterisk+cmd+System

Ian

lol,

Well here ya go… executing AGI(“SIP/3000 007D4Dc8:”, “ts-con.agi”) in new stack

yes running the script outside of asterisk works perfectly. Asterisk just wont run it. And to restate, this is AsteriskW32 on a 2003 server. So I am assuming that the cygroot might be part of the problem here. Asterisk might not be able to decide on a command interpreter, or the System() function may just not work in W32. But there has to be some little trick I am missing.

For example I can put notepad.exe in the dir and run… exten => 95,n,System(/usr/bin/notepad.exe)

Asterisk CLI reports that it executes but no notepad pops up. Verbose on 5 shows no errors.

Or I could be wrong on all that, thats why I am pulling the knowledge of the good people here. I mean… in my experienec there ALWAYS a way

lol.

Well I figured it out… and your post was helpful, thank you.

It seems that the System command calls the bin/sh

This in cygroot is /bin/sh.exe and that is what I had to make sure understood the commands I was trying to do. In the cygroot/bin there are many files ported for windows, including a perl.exe. Even though I had active perl installed I still had to go through the cygroot shell to run my script. What made it work was this:

exten => 95,n,System(perl.exe …/usr/bin/tscon.pl)

Then the shell in /cygroot/bin knew to use the perl.exe to run the scipt. Also notice that I had to use the … to get up a couple directories as the shell.exe runs in /bin. I had to go up to the root with … then back down to the appropiate directory.