Skip to content

Category Archives: Scripting

Python Two-Liner to Convert from a Unix Time Stamp

10-Dec-09

>>> import time
>>> time.gmtime(1253548874)
(2009, 9, 21, 16, 1, 14, 0, 264, 0)

Perl installation “best” practices

30-Dec-08

An old post, but one whose recommendations seem to work well – especially the part about installing as a non-root user – if you’re faced with an inflexible packaging of a system Perl that you don’t want to touch, like an RPM install. (Not needing to worry about things like this most of the time [...]

Bash Programming Cheat Sheet

30-Dec-08

A quick overview of Bash shell syntax: JustLinux’s Bash Programming Cheat Sheet.

Upgrading Perl 5.6 to Perl 5.8 Using Portupgrade and perl-after-upgrade

29-Dec-08

Use the -o flag to portupgrade to replace the perl5 port with a the perl5.8 port:
# portupgrade -rR -o lang/perl5.8 lang/perl5
After the upgrade (this is applicable after any Perl ports upgrade, such as 5.8.8 to 5.8.9), run the perl-after-upgrade script, first in test mode, then in fix mode:
# perl-after-upgrade
# perl-after-upgrade -f
Fix any errors highlighted by perl-after-upgrade, and reinstall any required packages. [...]

Loop Over Each Line in a File using Bash

28-Dec-08

Use exec as below, for example:
exec < $PASSWORD_FILE
while read LINE; do
user=`echo $LINE | cut -d: -f1`
uid=`echo $LINE | cut -d: -f3`
pgroup=`echo $LINE | cut -d: -f4`
homedir=`echo $LINE | cut -d: -f6`
shell=`echo $LINE | cut -d: -f7`
gecos=`echo $LINE | cut -d: -f5`
cmd=”/usr/sbin/useradd [...]