Scripting

Rename files in folder

Oneliner to rename files/directories. It converts ” ” into “_” and the characters to lower-case. $> perl -e ‘while(< *>) { $old=$_; s/ +/_/g; rename($old,lc($_)); }’ To limit it to a single filetype use it this way and replace ”.doc” with whatever you like. $> perl -e ‘while(< *.doc>) { $old=$_; s/ +/_/g; rename($old,lc($_)); }’

Read More
Network

Using TCP Wrappers to deny daemon access in specified hours

By doing the following you can deny certain daemons to be available in specified hours by using hosts.allow and hosts.deny. In my example I will be using the vsftpd daemon by adding tcp_wrapper=YES in /etc/vsftpd.conf. Make sure that your private network has access all the time by adding this in /etc/hosts.allow vsftpd: 192.168.0. Enables access […]

Read More
Web

Install Geo::IP Perl Module on Debian Etch

This post describes how to install MaxMind Geo::IP perl module on Debian Etch. You need the GeoIP C library (that includes also the free GeoLite Country database). This is fortunately available in the Debian repositories. apt-get install libgeoip1 libgeoip-dev To install the GeoIP perl module, we need to download the perl module locally from MaxMind […]

Read More
Scripting

Hints and Tips for general shell script programming

WARNING: this will fail if the user is playing with $0 For example using a symbolic or hard link with a unexpected name. # Simplest… # PROGNAME=`type $0 | awk ‘{print $3}’` # search for executable on path PROGNAME=`basename $PROGNAME` # base name of program # Advanced… # Script name, in what directory, and in […]

Read More