Re: [Asterisk-Users] realtime app data formatting
snacktime wrote: Here is a quick script that will parse extensions.conf, any files included via #include, and print out the sql commands to put them into mysql. I'll add on routines to do the same for sip, iax, and voicemail when I get the chance. Chris It seems I use the script wrong: vpbx:/etc/asterisk # ./extensions-mysql extensions.conf USE asterisk; Can't call method "close" on an undefined value at ./extensions-mysql line 72. extensions-mysql: - #!/usr/bin/perl # Copyright (c) 2005 Chris Ochs # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. use IO::File; $path = "/etc/asterisk"; my $database = "asterisk"; my $table = "extensions"; my $context; $file = $ARGV[0]; if(!-e "$path/$file" || $file eq '') { print "File does not exist\n"; exit; } print "USE $database;\n"; &parse_config($file); sub parse_config { my ($file) = @_; my $fh = IO::File->new("$path/$file"); while ($line = <$fh>) { chomp $line; if ($line =~/^\[(.*)\]$/) { $context = $1; }elsif ($line =~/(^[\s]{0,9}#include[\s]{0,9}.*$)/) { my $file_include = $1; $file_include =~s/#include[\s]{0,9}//g; $file_include =~s/\s//g; &parse_config($file_include); }elsif ($line =~/(^[\s]{0,9}exten[\s]{0,9}=>[\s]{0,9})([_.XN0-9a-zA-Z]{0,20}),([_.XN0-9a-zA-Z]{0,20}),(.*)/) { my (undef,$exten,$priority,$action) = ($1,$2,$3,$4); my ($app,$appdata); if ($action =~/(^[a-zA-Z]{0,32})\((.*)\)/) { ($app,$appdata) = ($1,$2); }elsif($action =~/(^[a-zA-Z]{0,32}),(.*)/) { ($app,$appdata) = ($1,$2); }else{ $app = $action; $appdata = ''; } $appdata =~s/,/\|/g; print "INSERT INTO extensions (context,exten,priority,app,appdata) VALUES ('$context', '$exten', '$priority', '$app', '$appdata');\n"; } } $fh->close; } ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- Ronald Wiplinger (CEO of ELMIT) http://www.elmit.com+886 (0) 939--77-55-16 or FWD 511208 - I'm a SpamCon Foundation Member, #694, Verify it at http://www.spamcon.org PS: Spam prevention! Our system is protected with a spam prevention program. If you send us an e-mail, our system will send you a confirmation message back. Just reply to this confirmation message please. After receiving this confirmation message, our system will send the hold message (one) and all future messages (after the received confirmation message) to me without asking you again. ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] realtime app data formatting
Here is a quick script that will parse extensions.conf, any files included via #include, and print out the sql commands to put them into mysql. I'll add on routines to do the same for sip, iax, and voicemail when I get the chance. Chris - #!/usr/bin/perl # Copyright (c) 2005 Chris Ochs # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. use IO::File; $path = "/etc/asterisk"; my $database = "asterisk"; my $table = "extensions"; my $context; $file = $ARGV[0]; if(!-e "$path/$file" || $file eq '') { print "File does not exist\n"; exit; } print "USE $database;\n"; &parse_config($file); sub parse_config { my ($file) = @_; my $fh = IO::File->new("$path/$file"); while ($line = <$fh>) { chomp $line; if ($line =~/^\[(.*)\]$/) { $context = $1; }elsif ($line =~/(^[\s]{0,9}#include[\s]{0,9}.*$)/) { my $file_include = $1; $file_include =~s/#include[\s]{0,9}//g; $file_include =~s/\s//g; &parse_config($file_include); }elsif ($line =~/(^[\s]{0,9}exten[\s]{0,9}=>[\s]{0,9})([_.XN0-9a-zA-Z]{0,20}),([_.XN0-9a-zA-Z]{0,20}),(.*)/) { my (undef,$exten,$priority,$action) = ($1,$2,$3,$4); my ($app,$appdata); if ($action =~/(^[a-zA-Z]{0,32})\((.*)\)/) { ($app,$appdata) = ($1,$2); }elsif($action =~/(^[a-zA-Z]{0,32}),(.*)/) { ($app,$appdata) = ($1,$2); }else{ $app = $action; $appdata = ''; } $appdata =~s/,/\|/g; print "INSERT INTO extensions (context,exten,priority,app,appdata) VALUES ('$context', '$exten', '$priority', '$app', '$appdata');\n"; } } $fh->close; } ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] realtime app data formatting
On 5/21/05, snacktime <[EMAIL PROTECTED]> wrote: > Got another question now after digging into this. How are regular > include statements and ignorepat implemented in realtime? Do I just > add them as additional fields to the extensions table I am using? > > Chris > Well that doesn't make any sense now that I look at it. Supporting them in realtime doesn't make any sense either really, so never mind on that question. Chris ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] realtime app data formatting
Got another question now after digging into this. How are regular include statements and ignorepat implemented in realtime? Do I just add them as additional fields to the extensions table I am using? Chris ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [Asterisk-Users] realtime app data formatting
Snacktime, I've found that the pipe thingy ( | ) is needed anywhere in your extensions table that a comma ( , ) would normally be. In your SIP peers/users/friends table/s, you need a semicolon ( ; ). This is as much as I know for sure at present :-) snacktime wrote: On the wiki it say's that if you use the Goto commands you need to replace ',' with '|' in the app data field. But in the examples it uses '|' in place of ',' in the Dial command also in a couple of places. Is it safe to replace ',' with '|' everywhere in the app data field when using realtime? Or should I still to substituting ',' with '|' only for the Goto commands? I'm putting together a quick perl script that parses extensions.conf and any include files, then writes out the sql commands to put everything into the database. I'll post it on the wiki when it's finished. Chris ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- Cheers, Mattt. VoIP made easy - http://voip.abovenetworks.net Convergent network specialists - http://abovenetworks.net I have an inferiority complex, but it's not a very good one... ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
[Asterisk-Users] realtime app data formatting
On the wiki it say's that if you use the Goto commands you need to replace ',' with '|' in the app data field. But in the examples it uses '|' in place of ',' in the Dial command also in a couple of places. Is it safe to replace ',' with '|' everywhere in the app data field when using realtime? Or should I still to substituting ',' with '|' only for the Goto commands? I'm putting together a quick perl script that parses extensions.conf and any include files, then writes out the sql commands to put everything into the database. I'll post it on the wiki when it's finished. Chris ___ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users