Archive for febbraio, 2014

Server DNS

apt-get install bind9 dnsutils

cd /etc/bind
mkdir -p zones/master
cd zones/master/


 /etc/init.d/bind9 start
Starting domain name service...: bind9.



Telnet router

Terminale: route [invio]

l’ip della riga default è quello del modem/router (di solito 192.168.1.1)

Terminale: telnet xxx.xxx.xxx.xxx [invio]

Inserisci user/psw

Se l’accesso telnet non è abilitato va configurato tramite interfaccia web del router

quick hacks

copy files from a directory to a destination by number offset:

 

#!/usr/bin/perl -w

use strict;
use Getopt::Std;
use File::Copy;

my %opts = ();
getopts('d:n:f:', \%opts);

my $dir = $opts{d};
my $num = $opts{n};
my $frm = $opts{f};
my $to_dir = '/var/log/'.$dir;

die "no directory : [$dir]\n"  unless -d $dir;
die "no files specified : [$num] (must be a number)\n" unless $num =~ m/^\d+$/;
if(defined($frm)) {
  die "no offset specified : [$frm] (must be a number)\n" unless $frm =~ m/^\d+$/;
}

print "processing dir :[$dir]\n";
print "files          :[$num]\n";

print"reading dir ....\n"; 
opendir(DIR, $dir) || die "can't opendir $dir: $!";
my @files = grep { ! /^\./ && -f "$dir/$_" } readdir(DIR);
closedir DIR;
print"dir read ....\n";

my $from = $frm || 0;
print">>DEBUG>>from:[$from]\n";

for (0 .. ($num - 1)) {
  $_ += $from;
  print"copying file:[$dir/$files[$_]] => $to_dir\n";
  copy("$dir/$files[$_]", $to_dir) or die "copy failed : $!\n";
}

__END__