I am using Asterisk Realtime Dialplan and a FuncODBC call within an Exec() to return a Dial() command.
I want to try and stick a command Set() before the Dial() conditionally depending on if I need to change the CALLERID(num). Is it possible to have multiple commands in a single Dialplan Exec() ?
If so then how can I piece them all together - seperating each function with a comma seems to fail in Asterisk 1.8
Some dialplan would help clarify what your trying to do, but from what I understood your looking for Execif() (use asterisk command core show application ExecIf to learn more)
Related
I would like to dynamically read an asterisk dialplan command from a (dynamically generated) file. Note: Within this file there can be a Dial() or a Playback() command, maybe later more than these two.
Is there any asterisk command or command combination that allows this? Something like
exten => 1234,1,ReadAndExecuteCommandFromFile("/foo/bar")
whereas "/foo/bar" contains one (1) line like
Dial(SIP/123456#provider)
or
Playback(something)
?
The functionality you are looking for is called AGI - Asterisk Gateway Interface. It will allow you to interact with the channel, in a synchronous manner. However, the "Commands" will be slightly different.
There are multiple scripting tool kits for AGI. If you are familiar with PHP, I suggest you have a look at PHPAGI, as it will give you the most bang for your buck in this case.
Simplest way use AGI is do like this:
exten => 1234,1,AGI(/bin/cat /foo/bar)
in /foo/bar file you need place AGI command
EXEC Dial SIP/123456#provider
or
EXEC Playback somefile
However more effective way use func_odbc function+dialplan or full AGI stack(better fast-AGI)
I have a Perl Script, that has (as of now) 10 subs and growing..
Each sub is making a different LWP-Call and is working with a variable I set in the first sub.
As each sub takes some time, I'm looking for a smart way to make the script run faster.
What would you recommend?
Should I:
Put each sub into a seperate script?
Call the subs (except the first) at once?
Use a different solution (that I don't know of)?
Thanks in advance!
EDIT:
The script is fetching some xml- and soap-data from the web, then extracting the necesary parts.
You probably want check the LWP::Parallel module.
ParallelUserAgent is an extension to the existing libwww module. It
allows you to take a list of URLs (it currently supports HTTP, FTP,
and FILE URLs. HTTPS might work, too) and connect to all of them in
parallel, then wait for the results to come in.
You dont have to split up the file if you dont want to. Just take a list of things to run on STDIN, then execute your script multiple times putting each process in the background or use cron if its an on going thing.
I would recommend using the Operating System's processes until you have a good reason not to do so anymore.
I've had success using Coro and there is already a module to do LWP requests.
http://metacpan.org/pod/LWP::Protocol::Coro::http
Coro is cooperative routines so not multithreaded. There is also an AnyEvent variation
I would like to call some Matlab functions using Erlang.
I have two separate network models (one comms/control, one energy)
Ideally I would like an Erlang process to send a message which causes some Matlab code to run. After the Matlab code has finished it must notify Erlang.
What is the simplest way of doing this?
I am running Windows 7. Matlab appears to require use of Microsoft Component Object Models which do not seem to be commonly used with Erlang - hence my question...
Thanks,
You can run Matlab statements from the command line:
matlab -r "statements"
Erlang gives you the opportunity to open ports to execute OS commands. Combining the two features should do the job for you. Have a look to the os:cmd/1 function. For example, you could simply do:
os:cmd("matlab -r STATEMENT").
I'm a Perl programmer doing some web application testing using Selenium. I was wondering if there's some kind of interactive interpreter which would allow me to type Selenium commands at a prompt and have them sent to selenium.
The way I'm currently developing code is to type all of the commands into a Perl script, and then execute the script. This make the development process painfully slow, because it makes it necessary to rerun the entire script whenever I make a change.
(If I were a Ruby programmer, I bet the Interactive Ruby Shell could help with this, but I'm hoping to find a solution for Perl.) Thanks!
The Java-based SeleniumServer has an --interactive mode.
I don't know about a Selenium shell, but if you are looking for a Perl REPL, there are modules such as Devel::REPL and Carp::REPL. I've made shells for various simple things using my Polyglot module, although I haven't looked at that in awhile.
May I ask why it's "necessary to re-run the entire script"? Since your solution is an interactive shell, i'm assuming that it's NOT because you need previous commands to set something up. If that's a correct assumption, simply make your set of Selenium commands in Perl script in such a way that you can skip the first N commands.
You can do it by explicit "if" wrappers.
Or you can have a generic "call a Selenium command based on a config hash" driver executed in a loop, and adding the config hash for every single Selenum command to an array of hashes.
Then you can either have an input parameter to the test script that refers to a # in an array; or you can even include unique labels for each test as a part of a config hash and pass "start with test named X" or even "only do test named X" as input on command line.
I have an asterisk-based PBX, and I have been able to successfully run an AGI script from the web control panel of the PBX.
Because I am calling AGI from Perl (neither of which I know, yet)...
asterisk commands look like this:
print "SET CALLERID $newcid \"\"\n";
So far, I don't expect to need to do any database lookups, etc. I simply want to set the caller ID (which I can do already) - then forward the call to a particular number.
Can anyone show me how to forward the current call using the AGI/perl style of executing asterisk commands shown above?
FYI: I've seen some examples using a format like:
Exten => blah blah....
But, I am not sure how to convert that to the AGI/perl format.
print "EXEC DIAL \"Zap/1/5551234567\"\n";
or, if you are using Asterisk::AGI,
$AGI->exec("DIAL", "Zap/1/5551234567");