RE: [Asterisk-Users] Re: Asterisk Question

2006-03-05 Thread Paul Hales

Find perl code attached:

while ($count = $BACK)
{
 print STDERR $count\n; 
 @item = pop(@text);
 print STDERR @item\n; 
 $count++;
}

regards,

PaulH

On Sat, 2006-03-04 at 07:54 -0800, Michael Collins wrote:
  I actually got it all working - but it's great to see where we did the
  same
  thing, and where we differ.
  
  I ended up using the 'pop' perl command - inside a loop to go back one
  item
  at a time through my list
  
  PaulH
 
 Nice work!  Perl = TMTOWTDI = There's More Than One Way To Do It
 -MC
 ___
 --Bandwidth and Colocation provided by Easynews.com --
 
 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
 

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-03-04 Thread Michael Collins
 I actually got it all working - but it's great to see where we did the
 same
 thing, and where we differ.
 
 I ended up using the 'pop' perl command - inside a loop to go back one
 item
 at a time through my list
 
 PaulH

Nice work!  Perl = TMTOWTDI = There's More Than One Way To Do It
-MC
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-03-03 Thread pdhales
I actually got it all working - but it's great to see where we did the same
thing, and where we differ.

I ended up using the 'pop' perl command - inside a loop to go back one item
at a time through my list

PaulH

- Original Message - 
From: Michael Collins [EMAIL PROTECTED]
To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
Sent: Thursday, March 02, 2006 6:21 AM
Subject: RE: [Asterisk-Users] Re: Asterisk Question


  Thanks for this example - it has really got me started!
 

 Paul,
 I did some tinkering and I think I found something that might be
 helpful.  If not, I did at least learn quite a bit about AGI scripting
 and dialplan writing! :)

 Okay, first I created a pretend file with numbers: /tmp/numbers.txt
 It is simply a list of numbers from 001 to 020, like so:
 001
 002
 003
 ...
 019
 020

 Since you have to check the file in reverse order, I have the AGI script
 read in the values, assign them to an array, @NUMS, then I perform a
 reverse on @NUMS:
 @NUMS = reverse @NUMS;

 Now 020 is the first value in the array, or $NUMS[0].
 019 is the second value, or $NUMS[1].

 If the number of previous messages that have been read (which I put in
 the dialplan variable NUM_MSGS_READ) is 0, then the next number is
 referenced by grabbing $NUMS[0].  If the number of previous messages
 that have been read is 1, then the next number is referenced by
 grabbing $NUMS[1], and so on.

 I created two different dialplan extensions so I could tinker.  The
 first one hard codes the value of NUM_MSGS_READ to 3.  Thus the return
 value of NEXT_NUM is $NUMS[3], which is 017.  The second one lets the
 caller enter in the value for NEXT_NUM, which is good for testing
 purposes.  I tried to add some validation logic to handle exceptions.  I
 didn't test it thoroughly but hopefully it illustrates the point.

 Here are the dialplan extensions:

 ; AGI test2.1
 ; hard coded NUM_MSGS_READ
 ;
 exten = 555,1,Noop(Starting AGI test)
 exten = 555,n,Answer
 exten = 555,n,Wait(1)
 exten = 555,n,SetVar(NUM_MSGS_READ=3)
 exten = 555,n,Playback(beep)
 exten = 555,n,AGI(agi_var_test2.pl)
 exten = 555,n,GotoIf($[${NEXT_NUM:1} = INVALID ]?invalid:ok)
 exten = 555,n(ok),SayDigits(${NEXT_NUM})
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,Hangup
 exten = 555,n(invalid),Playback(invalid)
 exten = 555,n,Hangup

 ; AGI test2.2
 ; For kicks, let the caller set the value of NUM_MSGS_READ
 ;
 exten = 556,1,Noop(Starting AGI test)
 exten = 556,n,Answer
 ;exten = 556,n,SetVar(NUM_MSGS_READ=X)
 exten = 556,n,Wait(1)
 exten = 556,n,Playback(please-enter-the)
 exten = 556,n,Playback(digits)
 exten = 556,n,Read(NUM_MSGS_READ,,2,,,10)
 exten = 556,n,Playback(beep)
 exten = 556,n,AGI(agi_var_test2.pl)
 exten = 556,n,GotoIf($[${NEXT_NUM:1} = INVALID ]?invalid:ok)
 exten = 556,n(ok),SayDigits(${NEXT_NUM})
 exten = 556,n,Wait(1)
 exten = 556,n,Playback(beep)
 exten = 556,n,Hangup
 exten = 556,n(invalid),Playback(invalid)
 exten = 556,n,Hangup
 exten = 556,t,Playback(vm-goodbye)
 exten = 556,t,Hangup


 The Read() application in exten 556 is configured to accept up to two
 digits with a 10 second digit timeout.  On a timeout it plays a goodbye
 message.  In both extensions, there is a test to make sure that NEXT_NUM
 doesn't contain the string INVALID - if it does then we go to a
 priority and voice that to the caller.  The AGI script will return
 1INVALID or 2INVALID depending upon why the script failed.  See the
 notes in the code for details.

 Here's the AGI script, agi_var_test2.pl:

 #!/usr/bin/perl
 #
 # agi_var_test2.pl
 #
 # Reads in info from file /tmp/numbers.txt into array @NUMS
 # Uses Asterisk var NUM_MSGS_READ to count from end of @NUMS
 # Assigns appropriate value from @NUMS to Asterisk var NEXT_NUM
 #
 use strict;
 use warnings;
 use Asterisk::AGI;

 # the AGI object
 my $agi = new Asterisk::AGI;

 # pull AGI variables into %input
 my %input = $agi-ReadParse();

 my @NUMS = (); # Array to hold data from file
 my $number;# Value to be sent back to Asterisk

 my $infile = '/tmp/numbers.txt';
 open(FILEIN,,$infile) or die $infile - $!\n;
 while(FILEIN) {
 chomp;

 # Perform some data validation, just to be safe
 s/^\s|\s+$|^\s+$//;# remove whitespace, just in case
 next unless length;# skip if nothing left...
 next unless m/^\d+$/;  # skip if line contains any non-digits
 push @NUMS,$_;
 } # while(FILEIN)
 close(FILEIN);

 # reverse array to make it easier to find our value
 # e.g. last line of file becomes first item in @NUMS:
 # $NUMS[0] = last item of file
 # $NUMS[1] = next to last item of file, etc.

 @NUMS = reverse @NUMS;

 my $arraypos = $agi-get_variable('NUM_MSGS_READ');
 if ( ! $arraypos ) {
 # if we get to this point, something is wrong...
 $agi-set_variable('NEXT_NUM','1INVALID');
 exit(1);# 1INVALID = AGI script could not read NUM_MSGS_READ
 }

 # since @NUMS is zero based, $arraypos = next

Re: [Asterisk-Users] Re: Asterisk Question

2006-03-02 Thread pdhales
Thanks to everyone who helped me with this!

I will post my code next week (when I am back at the workplace where I did
this)

later,

PaulH

- Original Message - 
From: Paul Hales [EMAIL PROTECTED]
To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
Sent: Wednesday, March 01, 2006 4:36 PM
Subject: Re: [Asterisk-Users] Re: Asterisk Question



 Perfection!

 PaulH

 On Tue, 2006-02-28 at 22:24 -0700, Darren Wiebe wrote:
  my ( $var1, $var2, $var3 ) =
@ARGV;
 
  and so on and so forth.
 
  Good Luck
 
  Darren Wiebe
  [EMAIL PROTECTED]
 
  Paul Hales wrote:
 
  Thanks for this example - it has really got me started!
  
  Short question - how can I put a variable into my perl script?
  
  I imagine it's something like
  exten = 780,1,AGI(agi_ret_val2.pl|${back})
  
  But how can I get my perl script to pick this value up?
  
  Again - thanks to everyone who has helped me with this.
  
  later,
  
  PaulH
  
  On Tue, 2006-02-28 at 11:25 -0800, Michael Collins wrote:
  
  
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:asterisk-users-
  [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
  Sent: Monday, February 27, 2006 7:53 PM
  To: Asterisk Users Mailing List - Non-Commercial Discussion
  Subject: Re: [Asterisk-Users] Re: Asterisk Question
  
  
  I was going to see if I can execute a bash script as an AGI - just
  
  
  looking
  
  
  around the internet for examples at the moment.
  Anybody got an example spare?
  I'm just a bit stuck on how to start this, but I am quite comfortable
  writing asterisk dialplan stuff and bash scripts
  
  later,
  
  PaulH
  
  
  
  Paul,
  
  I'm a Perl guy myself.  Here's a simple dialplan extension and AGI
  script written in Perl and using the very cool Asterisk::AGI module:
  
  ; AGI test
  exten = 555,1,Noop(Starting AGI test)
  exten = 555,n,Answer
  exten = 555,n,Wait(1)
  exten = 555,n,Playback(beep)
  exten = 555,n,AGI(agi_var_test.pl)
  exten = 555,n,SayDigits(${EXTERN_VAR})
  exten = 555,n,Wait(1)
  exten = 555,n,Playback(beep)
  exten = 555,n,Hangup
  
  
  Here's the Perl script:
  
  #!/usr/bin/perl
  #
  # agi_var_test.pl
  #
  # Reads in info from file /etc/group
  # assigns asterisk GID to Asterisk variable EXTERN_VAR
  #
  use strict;
  use warnings;
  use Asterisk::AGI;
  
  # the AGI object
  my $agi = new Asterisk::AGI;
  
  # pull AGI variables into %input
  my %input = $agi-ReadParse();
  
  my $infile = '/etc/group';
  open(FILEIN,,$infile) or die $infile - $!\n;
  while(FILEIN) {
  chomp;
  next unless m/^asterisk/;
  my @REC = split :,$_;
  print STDERR agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n;
  $agi-set_variable(EXTERN_VAR, $REC[2]);
  last;
  } # while(FILEIN)
  close(FILEIN);
  
  
  Basically the script just parses /etc/group until it finds the
asterisk
  entry.  It then parses the data line and extracts the GID.  Finally,
it
  prints the value to STDERR (for debugging purposes) and then assigns
the
  value to EXTERN_VAR.
  
  This is more a proof-of-concept than anything else, but it does show
the
  value of AGI and Asterisk::AGI.
  
  -MC
  ___
  --Bandwidth and Colocation provided by Easynews.com --
  
  Asterisk-Users mailing list
  To UNSUBSCRIBE or update options visit:
 http://lists.digium.com/mailman/listinfo/asterisk-users
  
  
  
  
  ___
  --Bandwidth and Colocation provided by Easynews.com --
  
  Asterisk-Users mailing list
  To UNSUBSCRIBE or update options visit:
 http://lists.digium.com/mailman/listinfo/asterisk-users
  
  
 
 

 ___
 --Bandwidth and Colocation provided by Easynews.com --

 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users


___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-03-01 Thread Michael Collins
 Thanks for this example - it has really got me started!
 

Paul, 
I did some tinkering and I think I found something that might be
helpful.  If not, I did at least learn quite a bit about AGI scripting
and dialplan writing! :)

Okay, first I created a pretend file with numbers: /tmp/numbers.txt
It is simply a list of numbers from 001 to 020, like so:
001
002
003
...
019
020

Since you have to check the file in reverse order, I have the AGI script
read in the values, assign them to an array, @NUMS, then I perform a
reverse on @NUMS:
@NUMS = reverse @NUMS;

Now 020 is the first value in the array, or $NUMS[0].
019 is the second value, or $NUMS[1].

If the number of previous messages that have been read (which I put in
the dialplan variable NUM_MSGS_READ) is 0, then the next number is
referenced by grabbing $NUMS[0].  If the number of previous messages
that have been read is 1, then the next number is referenced by
grabbing $NUMS[1], and so on.

I created two different dialplan extensions so I could tinker.  The
first one hard codes the value of NUM_MSGS_READ to 3.  Thus the return
value of NEXT_NUM is $NUMS[3], which is 017.  The second one lets the
caller enter in the value for NEXT_NUM, which is good for testing
purposes.  I tried to add some validation logic to handle exceptions.  I
didn't test it thoroughly but hopefully it illustrates the point.

Here are the dialplan extensions:

; AGI test2.1
; hard coded NUM_MSGS_READ
;
exten = 555,1,Noop(Starting AGI test)
exten = 555,n,Answer
exten = 555,n,Wait(1)
exten = 555,n,SetVar(NUM_MSGS_READ=3)
exten = 555,n,Playback(beep)
exten = 555,n,AGI(agi_var_test2.pl)
exten = 555,n,GotoIf($[${NEXT_NUM:1} = INVALID ]?invalid:ok)
exten = 555,n(ok),SayDigits(${NEXT_NUM})
exten = 555,n,Wait(1)
exten = 555,n,Playback(beep)
exten = 555,n,Hangup
exten = 555,n(invalid),Playback(invalid)
exten = 555,n,Hangup

; AGI test2.2
; For kicks, let the caller set the value of NUM_MSGS_READ
;
exten = 556,1,Noop(Starting AGI test)
exten = 556,n,Answer
;exten = 556,n,SetVar(NUM_MSGS_READ=X)
exten = 556,n,Wait(1)
exten = 556,n,Playback(please-enter-the)
exten = 556,n,Playback(digits)
exten = 556,n,Read(NUM_MSGS_READ,,2,,,10)
exten = 556,n,Playback(beep)
exten = 556,n,AGI(agi_var_test2.pl)
exten = 556,n,GotoIf($[${NEXT_NUM:1} = INVALID ]?invalid:ok)
exten = 556,n(ok),SayDigits(${NEXT_NUM})
exten = 556,n,Wait(1)
exten = 556,n,Playback(beep)
exten = 556,n,Hangup
exten = 556,n(invalid),Playback(invalid)
exten = 556,n,Hangup
exten = 556,t,Playback(vm-goodbye)
exten = 556,t,Hangup


The Read() application in exten 556 is configured to accept up to two
digits with a 10 second digit timeout.  On a timeout it plays a goodbye
message.  In both extensions, there is a test to make sure that NEXT_NUM
doesn't contain the string INVALID - if it does then we go to a
priority and voice that to the caller.  The AGI script will return
1INVALID or 2INVALID depending upon why the script failed.  See the
notes in the code for details.

Here's the AGI script, agi_var_test2.pl:

#!/usr/bin/perl
#
# agi_var_test2.pl
#
# Reads in info from file /tmp/numbers.txt into array @NUMS
# Uses Asterisk var NUM_MSGS_READ to count from end of @NUMS
# Assigns appropriate value from @NUMS to Asterisk var NEXT_NUM
#
use strict;
use warnings;
use Asterisk::AGI;

# the AGI object
my $agi = new Asterisk::AGI;

# pull AGI variables into %input
my %input = $agi-ReadParse();

my @NUMS = (); # Array to hold data from file
my $number;# Value to be sent back to Asterisk

my $infile = '/tmp/numbers.txt';
open(FILEIN,,$infile) or die $infile - $!\n;
while(FILEIN) {
chomp;

# Perform some data validation, just to be safe
s/^\s|\s+$|^\s+$//;# remove whitespace, just in case
next unless length;# skip if nothing left...
next unless m/^\d+$/;  # skip if line contains any non-digits
push @NUMS,$_;
} # while(FILEIN)
close(FILEIN);

# reverse array to make it easier to find our value
# e.g. last line of file becomes first item in @NUMS:
# $NUMS[0] = last item of file
# $NUMS[1] = next to last item of file, etc.

@NUMS = reverse @NUMS;

my $arraypos = $agi-get_variable('NUM_MSGS_READ');
if ( ! $arraypos ) {
# if we get to this point, something is wrong...
$agi-set_variable('NEXT_NUM','1INVALID');
exit(1);# 1INVALID = AGI script could not read NUM_MSGS_READ
}

# since @NUMS is zero based, $arraypos = next unread number
$number = $NUMS[$arraypos];
if ( $number ) {
$agi-set_variable('NEXT_NUM',$number);
exit(0);# Normal exit!
} else {
$agi-set_variable('NEXT_NUM','2INVALID');
exit(1);# 2INVALID = NUM_MSGS_READ larger than number of items
in @NUMS
}


Okay, that's all I've got for now.  Let us know how it goes!

-MC
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread [EMAIL PROTECTED]
On 28/02/06, Alexander Lopez [EMAIL PROTECTED] wrote:

 read STDIN
 while [ x$STDIN != x ]
 do
 export VARNAME=`echo $STDIN | cut -f1 -d :`
 export VARVALUE=`echo $STDIN |cut -f2 -d : | cut -c2-255`
 case $VARNAME in
 (agi_request) export AGIREQUEST=$VARVALUE;;
 (agi_channel) export AGICHANNEL=$VARVALUE;;
 (agi_language) export AGILANGUAGE=$VARVALUE;;
 (agi_type) export AGITYPE=$VARVALUE;;
 (agi_uniqueid) export AGIUNIQUEID=$VARVALUE;;
 (agi_callerid) export AGICALLERID=$VARVALUE;;
 (agi_calleridname) export
 AGICALLERIDNAME=$VARVALUE;;
 (agi_dnid) export AGIDNID=$VARVALUE;;
 (agi_rdnis) export AGIRDNIS=$VARVALUE;;
 (agi_context) export AGICONTEXT=$VARVALUE;;
 (agi_extension) export AGIEXTENSION=$VARVALUE;;
 (agi_priority) export AGIPRIORITY=$VARVALUE;;
 (agi_enhanced) export AGIENHANCED=$VARVALUE;;
 (agi_accountcode) export AGIACCOUNTCODE=$VARVALUE;;
 esac
 read STDIN
 done
 }
 #
 #  You now have all the stuff Asterisk gives you stored in Variables
 #
 #
 #   Do what ever you want here:
 #
 #



  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of
  [EMAIL PROTECTED]
  Sent: Monday, February 27, 2006 10:53 PM
  To: Asterisk Users Mailing List - Non-Commercial Discussion
  Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
  I was going to see if I can execute a bash script as an AGI -
  just looking around the internet for examples at the moment.
  Anybody got an example spare?
  I'm just a bit stuck on how to start this, but I am quite
  comfortable writing asterisk dialplan stuff and bash scripts
 
  later,
 
  PaulH
 ___
 --Bandwidth and Colocation provided by Easynews.com --

 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Michael Collins
Paul,

Just curious - what kind of stuff are you reading from the file?  
-MC

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:asterisk-users-
 [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
 Sent: Monday, February 27, 2006 7:53 PM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
 I was going to see if I can execute a bash script as an AGI - just
looking
 around the internet for examples at the moment.
 Anybody got an example spare?
 I'm just a bit stuck on how to start this, but I am quite comfortable
 writing asterisk dialplan stuff and bash scripts
 
 later,
 
 PaulH
 
  steve [EMAIL PROTECTED] wrote:
 
 
  From: Paul Hales [EMAIL PROTECTED]
  Subject: [Asterisk-Users] Asterisk question
  To: Asterisk Users Mailing List - Non-Commercial Discussion
 asterisk-users@lists.digium.com
  Message-ID: [EMAIL PROTECTED]
  Content-Type: text/plain
  
  Any idea how to read an external file, grab some stuff and push it
back
  into an Asterisk variable?
  
  I can do it the other way with:
  system(echo ${UNIQUEID} =  /home/ast/curr_calls)
  
  but I'm a bit stumped on how to go the other way around
  
  much thanks,
  
  Paul Hales
  
  
  
  I'll go out on a limb here and take a guess that it could be done as
an
  AGI script that incorporates SED (http://www.gnu.org/software/sed/)
and
  AWK (http://www.gnu.org/software/gawk/gawk.html).  I've used both
for
  some bash scripting in the past. . .
 
  Regards,
  Steve Cayona
  Super Technologies, Inc.
 
  ___
  --Bandwidth and Colocation provided by Easynews.com --
 
  Asterisk-Users mailing list
  To UNSUBSCRIBE or update options visit:
 http://lists.digium.com/mailman/listinfo/asterisk-users
 ___
 --Bandwidth and Colocation provided by Easynews.com --
 
 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Michael Collins
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:asterisk-users-
 [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
 Sent: Monday, February 27, 2006 7:53 PM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
 I was going to see if I can execute a bash script as an AGI - just
looking
 around the internet for examples at the moment.
 Anybody got an example spare?
 I'm just a bit stuck on how to start this, but I am quite comfortable
 writing asterisk dialplan stuff and bash scripts
 
 later,
 
 PaulH
 

Paul,

I'm a Perl man myself.  Here's a simple dialplan extension and
corresponding AGI script:

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Michael Collins
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:asterisk-users-
 [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
 Sent: Monday, February 27, 2006 7:53 PM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
 I was going to see if I can execute a bash script as an AGI - just
looking
 around the internet for examples at the moment.
 Anybody got an example spare?
 I'm just a bit stuck on how to start this, but I am quite comfortable
 writing asterisk dialplan stuff and bash scripts
 
 later,
 
 PaulH
 

Paul,

I'm a Perl guy myself.  Here's a simple dialplan extension and AGI
script written in Perl and using the very cool Asterisk::AGI module:

; AGI test
exten = 555,1,Noop(Starting AGI test)
exten = 555,n,Answer
exten = 555,n,Wait(1)
exten = 555,n,Playback(beep)
exten = 555,n,AGI(agi_var_test.pl)
exten = 555,n,SayDigits(${EXTERN_VAR})
exten = 555,n,Wait(1)
exten = 555,n,Playback(beep)
exten = 555,n,Hangup


Here's the Perl script:

#!/usr/bin/perl
#
# agi_var_test.pl
#
# Reads in info from file /etc/group
# assigns asterisk GID to Asterisk variable EXTERN_VAR
#
use strict;
use warnings;
use Asterisk::AGI;

# the AGI object
my $agi = new Asterisk::AGI;

# pull AGI variables into %input
my %input = $agi-ReadParse();

my $infile = '/etc/group';
open(FILEIN,,$infile) or die $infile - $!\n;
while(FILEIN) {
chomp;
next unless m/^asterisk/;
my @REC = split :,$_;
print STDERR agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n;
$agi-set_variable(EXTERN_VAR, $REC[2]);
last;
} # while(FILEIN)
close(FILEIN);


Basically the script just parses /etc/group until it finds the asterisk
entry.  It then parses the data line and extracts the GID.  Finally, it
prints the value to STDERR (for debugging purposes) and then assigns the
value to EXTERN_VAR.

This is more a proof-of-concept than anything else, but it does show the
value of AGI and Asterisk::AGI. 

-MC
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread pdhales
Numbers from a text file - just need to read them back in one at a time.

PaulH

- Original Message - 
From: Michael Collins [EMAIL PROTECTED]
To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
Sent: Wednesday, March 01, 2006 5:14 AM
Subject: RE: [Asterisk-Users] Re: Asterisk Question


 Paul,

 Just curious - what kind of stuff are you reading from the file?
 -MC

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:asterisk-users-
  [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
  Sent: Monday, February 27, 2006 7:53 PM
  To: Asterisk Users Mailing List - Non-Commercial Discussion
  Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
  I was going to see if I can execute a bash script as an AGI - just
 looking
  around the internet for examples at the moment.
  Anybody got an example spare?
  I'm just a bit stuck on how to start this, but I am quite comfortable
  writing asterisk dialplan stuff and bash scripts
 
  later,
 
  PaulH
 
   steve [EMAIL PROTECTED] wrote:
  
  
   From: Paul Hales [EMAIL PROTECTED]
   Subject: [Asterisk-Users] Asterisk question
   To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
   Message-ID: [EMAIL PROTECTED]
   Content-Type: text/plain
   
   Any idea how to read an external file, grab some stuff and push it
 back
   into an Asterisk variable?
   
   I can do it the other way with:
   system(echo ${UNIQUEID} =  /home/ast/curr_calls)
   
   but I'm a bit stumped on how to go the other way around
   
   much thanks,
   
   Paul Hales
   
   
   
   I'll go out on a limb here and take a guess that it could be done as
 an
   AGI script that incorporates SED (http://www.gnu.org/software/sed/)
 and
   AWK (http://www.gnu.org/software/gawk/gawk.html).  I've used both
 for
   some bash scripting in the past. . .
  
   Regards,
   Steve Cayona
   Super Technologies, Inc.
  
   ___
   --Bandwidth and Colocation provided by Easynews.com --
  
   Asterisk-Users mailing list
   To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users
  ___
  --Bandwidth and Colocation provided by Easynews.com --
 
  Asterisk-Users mailing list
  To UNSUBSCRIBE or update options visit:
 http://lists.digium.com/mailman/listinfo/asterisk-users
 ___
 --Bandwidth and Colocation provided by Easynews.com --

 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users



___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread pdhales
That's getting pretty close - thanks for that.

I just couldn't find any decent info on the web about working with AGI.

regards,

PaulH

- Original Message - 
From: Michael Collins [EMAIL PROTECTED]
To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
Sent: Wednesday, March 01, 2006 6:25 AM
Subject: RE: [Asterisk-Users] Re: Asterisk Question


  -Original Message-
  From: [EMAIL PROTECTED] [mailto:asterisk-users-
  [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
  Sent: Monday, February 27, 2006 7:53 PM
  To: Asterisk Users Mailing List - Non-Commercial Discussion
  Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
  I was going to see if I can execute a bash script as an AGI - just
 looking
  around the internet for examples at the moment.
  Anybody got an example spare?
  I'm just a bit stuck on how to start this, but I am quite comfortable
  writing asterisk dialplan stuff and bash scripts
 
  later,
 
  PaulH
 

 Paul,

 I'm a Perl guy myself.  Here's a simple dialplan extension and AGI
 script written in Perl and using the very cool Asterisk::AGI module:

 ; AGI test
 exten = 555,1,Noop(Starting AGI test)
 exten = 555,n,Answer
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,AGI(agi_var_test.pl)
 exten = 555,n,SayDigits(${EXTERN_VAR})
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,Hangup


 Here's the Perl script:

 #!/usr/bin/perl
 #
 # agi_var_test.pl
 #
 # Reads in info from file /etc/group
 # assigns asterisk GID to Asterisk variable EXTERN_VAR
 #
 use strict;
 use warnings;
 use Asterisk::AGI;

 # the AGI object
 my $agi = new Asterisk::AGI;

 # pull AGI variables into %input
 my %input = $agi-ReadParse();

 my $infile = '/etc/group';
 open(FILEIN,,$infile) or die $infile - $!\n;
 while(FILEIN) {
 chomp;
 next unless m/^asterisk/;
 my @REC = split :,$_;
 print STDERR agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n;
 $agi-set_variable(EXTERN_VAR, $REC[2]);
 last;
 } # while(FILEIN)
 close(FILEIN);


 Basically the script just parses /etc/group until it finds the asterisk
 entry.  It then parses the data line and extracts the GID.  Finally, it
 prints the value to STDERR (for debugging purposes) and then assigns the
 value to EXTERN_VAR.

 This is more a proof-of-concept than anything else, but it does show the
 value of AGI and Asterisk::AGI.

 -MC
 ___
 --Bandwidth and Colocation provided by Easynews.com --

 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users



___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Michael Collins

 That's getting pretty close - thanks for that.
 
 I just couldn't find any decent info on the web about working with
AGI.
 

Ditto.  However, I pieced some stuff together by sifting through my
well-worn copy of TFOT and bouncing around between the wiki, the sample
AGI scripts and asterisk.gnuinter.net.

I had never sat down to write an AGI script before - I hadn't needed one
- but I thought, How hard can it be?  Ugh.  The Asterisk::AGI module
is very handy, and I highly recommend it.  I've only written one AGI
script in my life (up to now) but I've written 10's of thousands of
lines of Perl and I know a good module when I see one.

Now, as far as reading one number at a time, are you reading one line
from the file at a time?  In other words, does your file look something
like this:
1237
2340
5434
123
9173
...

I was wondering what you were planning on doing with each number. Were
you looking at multiple passes to your AGI script, or were you going to
run the script once and collect all of the data in one pass?

-MC

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread pdhales
I need to read through the numbers in reverse order, so I can decide which
messages to play to people.

I was using a variable to mark how many messages they had read, and each
time read a number further back in the list.

PaulH

- Original Message - 
From: Michael Collins [EMAIL PROTECTED]
To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
Sent: Wednesday, March 01, 2006 9:22 AM
Subject: RE: [Asterisk-Users] Re: Asterisk Question



  That's getting pretty close - thanks for that.
 
  I just couldn't find any decent info on the web about working with
 AGI.
 

 Ditto.  However, I pieced some stuff together by sifting through my
 well-worn copy of TFOT and bouncing around between the wiki, the sample
 AGI scripts and asterisk.gnuinter.net.

 I had never sat down to write an AGI script before - I hadn't needed one
 - but I thought, How hard can it be?  Ugh.  The Asterisk::AGI module
 is very handy, and I highly recommend it.  I've only written one AGI
 script in my life (up to now) but I've written 10's of thousands of
 lines of Perl and I know a good module when I see one.

 Now, as far as reading one number at a time, are you reading one line
 from the file at a time?  In other words, does your file look something
 like this:
 1237
 2340
 5434
 123
 9173
 ...

 I was wondering what you were planning on doing with each number. Were
 you looking at multiple passes to your AGI script, or were you going to
 run the script once and collect all of the data in one pass?

 -MC

 ___
 --Bandwidth and Colocation provided by Easynews.com --

 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users



___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Johnathan Corgan
Michael Collins wrote:

 I had never sat down to write an AGI script before - I hadn't needed one
 - but I thought, How hard can it be?  Ugh.  The Asterisk::AGI module
 is very handy, and I highly recommend it.  I've only written one AGI
 script in my life (up to now) but I've written 10's of thousands of
 lines of Perl and I know a good module when I see one.

I'll second that.

I just wrote my first AGI script last night--using Python and the Pyst
AGI python library.  Works wonderfully.  Even with AEL, things get
cumbersome, and having the facilities of a true language really simplify
things.

-Johnathan
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Paul Hales

Thanks for this example - it has really got me started!

Short question - how can I put a variable into my perl script?

I imagine it's something like 
exten = 780,1,AGI(agi_ret_val2.pl|${back})

But how can I get my perl script to pick this value up?

Again - thanks to everyone who has helped me with this.

later,

PaulH

On Tue, 2006-02-28 at 11:25 -0800, Michael Collins wrote:
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:asterisk-users-
  [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
  Sent: Monday, February 27, 2006 7:53 PM
  To: Asterisk Users Mailing List - Non-Commercial Discussion
  Subject: Re: [Asterisk-Users] Re: Asterisk Question
  
  
  I was going to see if I can execute a bash script as an AGI - just
 looking
  around the internet for examples at the moment.
  Anybody got an example spare?
  I'm just a bit stuck on how to start this, but I am quite comfortable
  writing asterisk dialplan stuff and bash scripts
  
  later,
  
  PaulH
  
 
 Paul,
 
 I'm a Perl guy myself.  Here's a simple dialplan extension and AGI
 script written in Perl and using the very cool Asterisk::AGI module:
 
 ; AGI test
 exten = 555,1,Noop(Starting AGI test)
 exten = 555,n,Answer
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,AGI(agi_var_test.pl)
 exten = 555,n,SayDigits(${EXTERN_VAR})
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,Hangup
 
 
 Here's the Perl script:
 
 #!/usr/bin/perl
 #
 # agi_var_test.pl
 #
 # Reads in info from file /etc/group
 # assigns asterisk GID to Asterisk variable EXTERN_VAR
 #
 use strict;
 use warnings;
 use Asterisk::AGI;
 
 # the AGI object
 my $agi = new Asterisk::AGI;
 
 # pull AGI variables into %input
 my %input = $agi-ReadParse();
 
 my $infile = '/etc/group';
 open(FILEIN,,$infile) or die $infile - $!\n;
 while(FILEIN) {
 chomp;
 next unless m/^asterisk/;
 my @REC = split :,$_;
 print STDERR agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n;
 $agi-set_variable(EXTERN_VAR, $REC[2]);
 last;
 } # while(FILEIN)
 close(FILEIN);
 
 
 Basically the script just parses /etc/group until it finds the asterisk
 entry.  It then parses the data line and extracts the GID.  Finally, it
 prints the value to STDERR (for debugging purposes) and then assigns the
 value to EXTERN_VAR.
 
 This is more a proof-of-concept than anything else, but it does show the
 value of AGI and Asterisk::AGI. 
 
 -MC
 ___
 --Bandwidth and Colocation provided by Easynews.com --
 
 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
 

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Darren Wiebe

my ( $var1, $var2, $var3 ) =
 @ARGV;

and so on and so forth. 


Good Luck

Darren Wiebe
[EMAIL PROTECTED]

Paul Hales wrote:


Thanks for this example - it has really got me started!

Short question - how can I put a variable into my perl script?

I imagine it's something like 
exten = 780,1,AGI(agi_ret_val2.pl|${back})


But how can I get my perl script to pick this value up?

Again - thanks to everyone who has helped me with this.

later,

PaulH

On Tue, 2006-02-28 at 11:25 -0800, Michael Collins wrote:
 


-Original Message-
From: [EMAIL PROTECTED] [mailto:asterisk-users-
[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Monday, February 27, 2006 7:53 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] Re: Asterisk Question


I was going to see if I can execute a bash script as an AGI - just
 


looking
   


around the internet for examples at the moment.
Anybody got an example spare?
I'm just a bit stuck on how to start this, but I am quite comfortable
writing asterisk dialplan stuff and bash scripts

later,

PaulH

 


Paul,

I'm a Perl guy myself.  Here's a simple dialplan extension and AGI
script written in Perl and using the very cool Asterisk::AGI module:

; AGI test
exten = 555,1,Noop(Starting AGI test)
exten = 555,n,Answer
exten = 555,n,Wait(1)
exten = 555,n,Playback(beep)
exten = 555,n,AGI(agi_var_test.pl)
exten = 555,n,SayDigits(${EXTERN_VAR})
exten = 555,n,Wait(1)
exten = 555,n,Playback(beep)
exten = 555,n,Hangup


Here's the Perl script:

#!/usr/bin/perl
#
# agi_var_test.pl
#
# Reads in info from file /etc/group
# assigns asterisk GID to Asterisk variable EXTERN_VAR
#
use strict;
use warnings;
use Asterisk::AGI;

# the AGI object
my $agi = new Asterisk::AGI;

# pull AGI variables into %input
my %input = $agi-ReadParse();

my $infile = '/etc/group';
open(FILEIN,,$infile) or die $infile - $!\n;
while(FILEIN) {
   chomp;
   next unless m/^asterisk/;
   my @REC = split :,$_;
   print STDERR agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n;
   $agi-set_variable(EXTERN_VAR, $REC[2]);
   last;
} # while(FILEIN)
close(FILEIN);


Basically the script just parses /etc/group until it finds the asterisk
entry.  It then parses the data line and extracts the GID.  Finally, it
prints the value to STDERR (for debugging purposes) and then assigns the
value to EXTERN_VAR.

This is more a proof-of-concept than anything else, but it does show the
value of AGI and Asterisk::AGI. 


-MC
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

   



___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users
 




--
Darren Wiebe
[EMAIL PROTECTED]
Aleph Communications
ASTPP - Open Source Voip Billing  Calling Cards
www.aleph-com.net/astpp

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Paul Hales

Perfection!

PaulH

On Tue, 2006-02-28 at 22:24 -0700, Darren Wiebe wrote:
 my ( $var1, $var2, $var3 ) =
   @ARGV;
 
 and so on and so forth. 
 
 Good Luck
 
 Darren Wiebe
 [EMAIL PROTECTED]
 
 Paul Hales wrote:
 
 Thanks for this example - it has really got me started!
 
 Short question - how can I put a variable into my perl script?
 
 I imagine it's something like 
 exten = 780,1,AGI(agi_ret_val2.pl|${back})
 
 But how can I get my perl script to pick this value up?
 
 Again - thanks to everyone who has helped me with this.
 
 later,
 
 PaulH
 
 On Tue, 2006-02-28 at 11:25 -0800, Michael Collins wrote:
   
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:asterisk-users-
 [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
 Sent: Monday, February 27, 2006 7:53 PM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
 I was going to see if I can execute a bash script as an AGI - just
   
 
 looking
 
 
 around the internet for examples at the moment.
 Anybody got an example spare?
 I'm just a bit stuck on how to start this, but I am quite comfortable
 writing asterisk dialplan stuff and bash scripts
 
 later,
 
 PaulH
 
   
 
 Paul,
 
 I'm a Perl guy myself.  Here's a simple dialplan extension and AGI
 script written in Perl and using the very cool Asterisk::AGI module:
 
 ; AGI test
 exten = 555,1,Noop(Starting AGI test)
 exten = 555,n,Answer
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,AGI(agi_var_test.pl)
 exten = 555,n,SayDigits(${EXTERN_VAR})
 exten = 555,n,Wait(1)
 exten = 555,n,Playback(beep)
 exten = 555,n,Hangup
 
 
 Here's the Perl script:
 
 #!/usr/bin/perl
 #
 # agi_var_test.pl
 #
 # Reads in info from file /etc/group
 # assigns asterisk GID to Asterisk variable EXTERN_VAR
 #
 use strict;
 use warnings;
 use Asterisk::AGI;
 
 # the AGI object
 my $agi = new Asterisk::AGI;
 
 # pull AGI variables into %input
 my %input = $agi-ReadParse();
 
 my $infile = '/etc/group';
 open(FILEIN,,$infile) or die $infile - $!\n;
 while(FILEIN) {
 chomp;
 next unless m/^asterisk/;
 my @REC = split :,$_;
 print STDERR agi_var_test.pl: Setting EXTERN_VAR to $REC[2]\n;
 $agi-set_variable(EXTERN_VAR, $REC[2]);
 last;
 } # while(FILEIN)
 close(FILEIN);
 
 
 Basically the script just parses /etc/group until it finds the asterisk
 entry.  It then parses the data line and extracts the GID.  Finally, it
 prints the value to STDERR (for debugging purposes) and then assigns the
 value to EXTERN_VAR.
 
 This is more a proof-of-concept than anything else, but it does show the
 value of AGI and Asterisk::AGI. 
 
 -MC
 ___
 --Bandwidth and Colocation provided by Easynews.com --
 
 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
 
 
 
 
 ___
 --Bandwidth and Colocation provided by Easynews.com --
 
 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
   
 
 
 

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-28 Thread Michael Collins
 Thanks for this example - it has really got me started!
 
 Short question - how can I put a variable into my perl script?
 
 I imagine it's something like
 exten = 780,1,AGI(agi_ret_val2.pl|${back})
 
 But how can I get my perl script to pick this value up?
 
 Again - thanks to everyone who has helped me with this.
 

Paul,

You can also set an Asterisk variable and access it with the
get_variable method of Asterisk::AGI:

extensions.conf:
exten = 780,1,SetVar(MyVar=test)
exten = 780,n,AGI(agi_ret_val2.pl)


In agi_ret_val2.pl:

my $var = $agi-get_variable('MyVar');

I'm using this with a proof on concept script.  I'll post it tomorrow
when I'm done.

-MC
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


[Asterisk-Users] Re: Asterisk Question

2006-02-27 Thread steve



From: Paul Hales [EMAIL PROTECTED]
Subject: [Asterisk-Users] Asterisk question
To: Asterisk Users Mailing List - Non-Commercial Discussion
asterisk-users@lists.digium.com
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain

Any idea how to read an external file, grab some stuff and push it back
into an Asterisk variable?

I can do it the other way with:
system(echo ${UNIQUEID} =  /home/ast/curr_calls) 


but I'm a bit stumped on how to go the other way around

much thanks,

Paul Hales

 

I'll go out on a limb here and take a guess that it could be done as an 
AGI script that incorporates SED (http://www.gnu.org/software/sed/) and 
AWK (http://www.gnu.org/software/gawk/gawk.html).  I've used both for 
some bash scripting in the past. . .


Regards,
Steve Cayona
Super Technologies, Inc.

___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] Re: Asterisk Question

2006-02-27 Thread pdhales

I was going to see if I can execute a bash script as an AGI - just looking 
around the internet for examples at the moment.
Anybody got an example spare? 
I'm just a bit stuck on how to start this, but I am quite comfortable writing 
asterisk dialplan stuff and bash scripts

later,

PaulH

 steve [EMAIL PROTECTED] wrote:
 
 
 From: Paul Hales [EMAIL PROTECTED]
 Subject: [Asterisk-Users] Asterisk question
 To: Asterisk Users Mailing List - Non-Commercial Discussion
  asterisk-users@lists.digium.com
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain
 
 Any idea how to read an external file, grab some stuff and push it back
 into an Asterisk variable?
 
 I can do it the other way with:
 system(echo ${UNIQUEID} =  /home/ast/curr_calls) 
 
 but I'm a bit stumped on how to go the other way around
 
 much thanks,
 
 Paul Hales
 
   
 
 I'll go out on a limb here and take a guess that it could be done as an 
 AGI script that incorporates SED (http://www.gnu.org/software/sed/) and 
 AWK (http://www.gnu.org/software/gawk/gawk.html).  I've used both for 
 some bash scripting in the past. . .
 
 Regards,
 Steve Cayona
 Super Technologies, Inc.
 
 ___
 --Bandwidth and Colocation provided by Easynews.com --
 
 Asterisk-Users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Re: Asterisk Question

2006-02-27 Thread Alexander Lopez
 
read STDIN
while [ x$STDIN != x ]
do
export VARNAME=`echo $STDIN | cut -f1 -d :`
export VARVALUE=`echo $STDIN |cut -f2 -d : | cut -c2-255`
case $VARNAME in
(agi_request) export AGIREQUEST=$VARVALUE;;
(agi_channel) export AGICHANNEL=$VARVALUE;;
(agi_language) export AGILANGUAGE=$VARVALUE;;
(agi_type) export AGITYPE=$VARVALUE;;
(agi_uniqueid) export AGIUNIQUEID=$VARVALUE;;
(agi_callerid) export AGICALLERID=$VARVALUE;;
(agi_calleridname) export
AGICALLERIDNAME=$VARVALUE;;
(agi_dnid) export AGIDNID=$VARVALUE;;
(agi_rdnis) export AGIRDNIS=$VARVALUE;;
(agi_context) export AGICONTEXT=$VARVALUE;;
(agi_extension) export AGIEXTENSION=$VARVALUE;;
(agi_priority) export AGIPRIORITY=$VARVALUE;;
(agi_enhanced) export AGIENHANCED=$VARVALUE;;
(agi_accountcode) export AGIACCOUNTCODE=$VARVALUE;;
esac
read STDIN
done
}
#
#  You now have all the stuff Asterisk gives you stored in Variables
#
#
#   Do what ever you want here:
#
#



 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 [EMAIL PROTECTED]
 Sent: Monday, February 27, 2006 10:53 PM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] Re: Asterisk Question
 
 
 I was going to see if I can execute a bash script as an AGI - 
 just looking around the internet for examples at the moment.
 Anybody got an example spare? 
 I'm just a bit stuck on how to start this, but I am quite 
 comfortable writing asterisk dialplan stuff and bash scripts
 
 later,
 
 PaulH
___
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users