#!/usr/local/bin/perl -w use Mail::Box::IMAP4; my $f = Mail::Box::IMAP4->new(host => "10.X.X.X", username => "someuser", password => "somepassword", folder => "GENERADOR DE LISTAS", trace => 3, debug => 3) or die "Can't connect: $@"; foreach my $msg ($f->messages) { print "Message header: [".$msg->getHead()."]\n"; } #### #!/usr/bin/perl -w my $NamedPipe = "/home/test/perl/named-pipes/.to-monica"; print "Reading from $NamedPipe\n"; open(FIFO, "< $NamedPipe") || die "Cant open $NamedPipe: $!"; while(1) #### This is UUUUGLY { while() { chomp; print "I got: [".$_."]\n"; } } close FIFO; #### my %IniStruct = ( qr/^MONICACTE RAIZ$/ => { qr/^DEPURACION$/ => qr/^(SI|NO)$/, qr/^DIRBASE$/ => { "EXPREG" => qr/^\/\w+[\/\w]*$/, "VALOR" => "-e ARCHIVO && -d _ && -r _", }, qr/^LOGFILE$/ => { "EXPREG" => qr/^\w+[\/\w]*$/, "VALOR" => "-e ARCHIVO && -f _ && -T _ && -r _ && -w _", }, qr/^MONICASRVADDR$/ => qr/^\d{1,3}\.\d{1,2}\.\d{1,2}\.\d{1,3}$/, qr/^CONNECTIONTIMEOUT$/ => qr/^\d{1,2}$/, qr/^MONICACTE CAT=\w+/ => { qr/^HABILITAR$/ => qr/^(SI|NO)$/, qr/^DEPURAR$/ => qr/^(SI|NO)$/, qr/^CAT=\w+ SUBCAT=\w+$/ => { qr/^HABILITAR$/ => qr/^(SI|NO)$/, qr/^DEPURAR$/ => qr/^(SI|NO)$/, }, qr/^SUBCAT=\w+ (PARAM=[\/\w]+|GPO=\w+)$/ => { qr/^SCRIPT$/ => { "EXPREG" => qr/^\/\w+[\/\w]*$/, "VALOR" => "-e ARCHIVO && -s _ && -r _ && -x _", }, qr/^ARGUMENTOS$/ => qr/.*/, qr/^EXPREG$/ => qr/.*/, }, }, }, ); my $CfgFileOb = new Config::IniFiles( -file => $ARGV[0] ); my ($RegExpRaiz, $Valor) = each(%IniStruct); foreach my $MatchingSection( grep(/$RegExpRaiz/, $CfgFileOb->Sections()) ) { print "$MatchingSection\tCoincide con regexpheader\n"; if (ref( qr($Valor) ) eq "Regexp") { print "regexp\n"; } elsif (ref( $Valor ) eq "HASH" ) { } else { } } #### Conjunto de frames #### use strict; use CGI ':standard'; use HTML::Template; use DBI; my $BaseDatos = "dbi:SQLite:dbname=./personal.db3"; my $dbh = DBI->connect( $BaseDatos, "", "", { RaiseError => 1 } ) || die "ERR al conectarse a $BaseDatos: $DBI::errstr"; DBI->trace(1); my $template = HTML::Template->new( filename => 'sel_instancia.tmpl' ); my @hostnames = (); my @hosts = @{ $dbh->selectall_arrayref( "SELECT hostname FROM hosts", { Slice => {} } ) }; foreach my $host( @hosts ) { push @hostnames, $host->{hostname}; } $template->param(HOSTS => \@hosts); $dbh->disconnect; print "Content-type: text/html\n\n"; print $template->output; #### use IO::Socket; my $SrvSaraPort = "10.180.19.19"; my $SrvSaraPort = "9001"; $server = IO::Socket::INET->new(Proto => 'tcp', LocalPort => $SrvSaraPort, Listen => SOMAXCONN, Reuse => 1); while($client = $server->accept()) { $client->autoflush(1); next unless $client->peerhost eq $SrvMonicaAddr; my $RcvString = <$client>; print $client "OK"; } close $client #### use Tk; use Tk::HList; @ElementsList = ("one", "two", "three"); @SubElementsList = ("four", "five", "six"); @Hosts = ("this", "that", "them"); $mw = MainWindow->new; $upperframe = $mw->Frame(-relief => 'groove', -borderwidth => 3, )->pack(-side => 'top', -fill => 'x'); $label=$upperframe->Label(-text => "TEXT")->pack(-side => 'left'); $label->pack; $label->bind('' => sub { $mw->destroy }); $middleframe = $mw->Frame(-relief => 'groove', -borderwidth => 3, )->pack(-side => 'top', -fill => 'x'); $list=$middleframe->Scrolled(qw/Listbox -setgrid 1 -height 10 -scrollbars e/ )->pack(qw/-side left -expand yes -fill both/); $list->focus; $list->bind('' => sub { showdata($_[0]->get('active')) }); $list->insert(0, @Hosts); $list->activate(0); $lowerframe = $mw->Frame(-relief => 'groove', -borderwidth => 3, )->pack(-side => 'top', -fill => 'x'); $CfgDisplay = $lowerframe->Scrolled(qw\HList -separator | -selectmode extended -width 55 -height 20 -indent 35 -scrollbars se\ )->grid(qw/-sticky nsew/); MainLoop; sub showdata { $CfgDisplay->delete(all); foreach my $element(@ElementsList) { $CfgDisplay->add($element, -text => $element, -data => $element); foreach my $subelement(@SubElementsList) { $CfgDisplay->add("$element|$subelement", -text => $subelement, -data => $subelement); } } } #### my @resultados = `rsh worst-station -l ab-user ls -lta /space`; open(LOG, ">archivo.txt") || die "fallo: $!"; print LOG @resultados; close LOG;