Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts
Tuesday, March 19, 2013
CPAN and RRDs.pm of rrdtool
1. upgrade CPAN
cpan> install CPAN
cpan> reload cpan
2. install App::Cpan to use the `cpan -I` switch
3. then, local::lib can be compiled and installed!
4. #pkg_add p5-RRD
REFERENCE:
http://www.perlmonks.org/?node_id=637987
http://search.cpan.org/dist/local-lib/lib/local/lib.pm#The_bootstrapping_technique
http://my14all.sourceforge.net/install.html
Monday, March 18, 2013
batch adding users with perl
#!/usr/bin/perl
# The format is username:password:shell:homedir:groupname
open FILE, $ARGV[0] or die "Cannot open file: $!";
foreach $line (@lines=<FILE>){
chomp($line);
($name,$pass,$shel,$dirc,$grup)=split(/:/,$line);
chomp($epas=`encrypt $pass`);
system "useradd -s $shel -d $dirc -g $grup -p '$epas' $name";
#print $epas,"\n";
$pattern="^".$name."\$";
open CHROOTFILE, "/etc/ftpchroot" or die "Cannot open file: $!";
open APPENDFILE, ">>/etc/ftpchroot" or die "Cannot append file: $!";
if(!grep (/$pattern/,<CHROOTFILE>)) {print APPENDFILE "$name\n";}
}
Sunday, August 26, 2012
using Perl and CPAN
OpenBSD ships with recent version of Perl. For example, 5.12 with OpenBSD 5.1.
Therefore, we can simple code in Perl with its powerful CPAN library if you lack of anything in your OpenBSD box!
Therefore, we can simple code in Perl with its powerful CPAN library if you lack of anything in your OpenBSD box!
Subscribe to:
Posts (Atom)