Vincent Delporte
2007-May-14 22:45 UTC
[asterisk-users] [*Win32 0.60] Sending call notification by e-mail/web?
Hello, In case there are other users of the AsteriskWin32 port... I haven't really used the AGI feature of Asterisk to run an application from extensions.conf. *Win32 supports Perl, which I don't know. Apparently, it's also possible to write AGI applications as EXE's (there's a eagi-test.exe file installed by default). => When a call comes in, I'd like an AGI application to send an e-mail and send CID name/number to a script on a web server. Is this the correct way to do it in Perl, with the modules available in AsteriskWin32? Could I rewrite this in Delphi instead? --------------------------------------------------- #!/usr/bin/perl ;--------------------------------------------------- ;Note: Not sure if *Win32 supports LWP::Simple and Net::SMTP! ;Called from extensions.conf ;exten => group,n,AGI(notify.agi|${CALLERID(num)}|${CALLERID(name)}) ;--------------------------------------------------- use strict; open STDOUT, '>/dev/null'; fork and exit; ;--------------------------------------------------- use LWP::Simple; my $cidnum = $ARGV[0]; my $cidname = $ARGV[1]; my $url = 'http://www.acme.com/input.php?name=$cidname&number=$cidnum'; my $content = get $url; die "Couldn't get $url" unless defined $content; print STDERR "Notified web server" ;--------------------------------------------------- use Net::SMTP; $smtp = Net::SMTP->new('smtp.acme.com'); # connect to an SMTP server $smtp->mail( 'asterisk@acme.com' ); # use the sender's address here $smtp->to('calls@acme.com'); # recipient's address $smtp->data(); # Start the mail # Send the header. $smtp->datasend("To: calls@acme.com\n"); $smtp->datasend("From: asterisk@acme.com\n"); $smtp->datasend("\n"); # Send the body. $smtp->datasend("Call received from $cidname/$cidnum\n"); $smtp->dataend(); # Finish sending the mail $smtp->quit; print STDERR "Send e-mail" --------------------------------------------------- Thanks for any tip
Nick Seraphin
2007-May-14 23:43 UTC
[asterisk-users] [*Win32 0.60] Sending call notification by e-mail/web?
On Tue, 15 May 2007, Vincent Delporte wrote:> Hello, > > In case there are other users of the AsteriskWin32 port... > > I haven't really used the AGI feature of Asterisk to run an application > from extensions.conf. *Win32 supports Perl, which I don't know. Apparently, > it's also possible to write AGI applications as EXE's (there's a > eagi-test.exe file installed by default). > > => When a call comes in, I'd like an AGI application to send an e-mail and > send CID name/number to a script on a web server. > > Is this the correct way to do it in Perl, with the modules available in > AsteriskWin32? Could I rewrite this in Delphi instead?ALL AGI scripts are basically just programs that read from stdin and write to stdout. They can therefore be written in almost any language. So yes, Delphi should work fine. (I have very fond memories of Delphi, and before that, Borland Pascal w/ Objects for DOS, and before that, Turbo Pascal... one of these days I'll have to get the latest version of Delphi and take a walk down memory lane. These days everything is C this or Perl that. I loved Pascal. :-)) -- Nick
Time Bandit
2007-May-15 05:40 UTC
[asterisk-users] [*Win32 0.60] Sending call notification by e-mail/web?
> Could I rewrite this in Delphi instead?I never used Delphi to write an AGI but I've seen a class in FreePascal that you could probably use as a base : http://www.automated.it/asterisk/fpc-agi.html hth
Lee Jenkins
2007-May-15 12:54 UTC
[asterisk-users] [*Win32 0.60] Sending call notification by e-mail/web?
Vincent Delporte wrote:> Hello, > > In case there are other users of the AsteriskWin32 port... > > I haven't really used the AGI feature of Asterisk to run an application > from extensions.conf. *Win32 supports Perl, which I don't know. > Apparently, it's also possible to write AGI applications as EXE's > (there's a eagi-test.exe file installed by default). > > => When a call comes in, I'd like an AGI application to send an e-mail > and send CID name/number to a script on a web server. > > Is this the correct way to do it in Perl, with the modules available in > AsteriskWin32? Could I rewrite this in Delphi instead? >Vincent, Freepascal seems to work very nicely. However, I'm not sure how delphi behaves with stdin/stdout since I've not written many console apps in delphi, mostly GUI rich software. The best bet would be as another poster suggested and to write a FastAGI server. If you don't feel like writing a FastAGI server, you can also take a look at AsterPas which is a pascal based FastAGI server for both Windows and Linux (written in freepascal): http://www.datatrakpos.com/pos/datatalk/asterpas.aspx It's still in beta, but works very well. You can check out some scripts that I've written so far: http://www.leebo.dreamhosters.com/apscripts/ -- Warm Regards, Lee
Lee Jenkins
2007-May-15 13:07 UTC
[asterisk-users] [*Win32 0.60] Sending call notification by e-mail/web?
Vincent Delporte wrote:> Hello, > > In case there are other users of the AsteriskWin32 port... > > I haven't really used the AGI feature of Asterisk to run an application > from extensions.conf. *Win32 supports Perl, which I don't know. > Apparently, it's also possible to write AGI applications as EXE's > (there's a eagi-test.exe file installed by default). > > => When a call comes in, I'd like an AGI application to send an e-mail > and send CID name/number to a script on a web server. > > Is this the correct way to do it in Perl, with the modules available in > AsteriskWin32? Could I rewrite this in Delphi instead? >Vincent, Freepascal seems to work very nicely. However, I'm not sure how delphi behaves with stdin/stdout since I've not written many console apps in delphi, mostly GUI rich software. The best bet would be as another poster suggested and to write a FastAGI server. If you don't feel like writing a FastAGI server, you can also take a look at AsterPas which is a pascal based FastAGI server for both Windows and Linux (written in freepascal): http://www.datatrakpos.com/pos/datatalk/asterpas.aspx It's still in beta, but works very well. You can check out some scripts that I've written so far: http://www.leebo.dreamhosters.com/apscripts/ We're planning on adding a mail client class to the scripting engine soon. -- Warm Regards, Lee