Skip to content

Instantly share code, notes, and snippets.

@hlegius
Created August 31, 2010 11:30
Show Gist options
  • Save hlegius/558894 to your computer and use it in GitHub Desktop.
Save hlegius/558894 to your computer and use it in GitHub Desktop.
[Perl] Leitura de linhas para o Asterisk
#!/usr/bin/perl
#Script para o usuário escolher por quais portas ZAP as ligações irão sair.
#Com esse script, o usuário não tem a necessidade de editar o zapata.conf, nem dar reload no módulo zap nem no Asterisk.
print "Digite os ramais separando-os por virgulas:\n";
$line = <>;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
@args = split(',', $line);
$macro = "";
$macro_firstline = "macro disca_portas(";
$index = 1;
foreach $ramal (@args) {
$macro .= "Dial(ZAP/$ramal/\$\{DST\},60,tTwW);\n";
$macro .= "&dial_status();\n";
$lineArg .= "$ramal,";
++$index;
}
chop($lineArg);
#$macro_firstline .= $lineArg . ") {\n";
$macro_firstline .= "DST) {\n";
$macro_firstline .= $macro .= "};";
system ("echo '$macro_firstline' > extensions_disca_canais.ael");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment