Thursday, May 26, 2011

Convert AWK to Perl using a2p

Automatic conversion of AWK scripts to perl.

A little awk script that numbers lines:
ls -la /usr | ./linum.pl
1 : total 240
2 : drwxr-xr-x+ 12 root root 4096 2010-06-21 06:47 .
3 : drwxr-xr-x 22 root root 4096 2011-05-11 12:06 ..
4 : drwxr-xr-x+ 2 root root 69632 2011-05-24 14:07 bin
5 : drwxr-xr-x+ 2 root root 4096 2010-05-05 11:33 games
6 : drwxr-xr-x+ 5 root root 4096 2010-06-21 06:47 i586-suse-linux
7 : drwxr-xr-x+ 52 root root 4096 2011-05-13 04:17 include
8 : drwxr-xr-x+ 156 root root 69632 2011-05-24 14:07 lib
9 : drwxr-xr-x+ 10 root root 4096 2010-06-21 06:47 local
10 : drwxr-xr-x+ 2 root root 12288 2011-05-24 14:07 sbin
11 : drwxr-xr-x+ 213 root root 4096 2011-05-23 13:19 share
Let's convert this to perl using a2p.
echo '{ printf("%5d : %s\n", NR, $0) }' | a2p > linum.pl
chmod +x linum.pl
Let's try it out:
ls -la /usr | ./linum.pl
1 : total 240
2 : drwxr-xr-x+ 12 root root 4096 2010-06-21 06:47 .
3 : drwxr-xr-x 22 root root 4096 2011-05-11 12:06 ..
4 : drwxr-xr-x+ 2 root root 69632 2011-05-24 14:07 bin
5 : drwxr-xr-x+ 2 root root 4096 2010-05-05 11:33 games
6 : drwxr-xr-x+ 5 root root 4096 2010-06-21 06:47 i586-suse-linux
7 : drwxr-xr-x+ 52 root root 4096 2011-05-13 04:17 include
8 : drwxr-xr-x+ 156 root root 69632 2011-05-24 14:07 lib
9 : drwxr-xr-x+ 10 root root 4096 2010-06-21 06:47 local
10 : drwxr-xr-x+ 2 root root 12288 2011-05-24 14:07 sbin
11 : drwxr-xr-x+ 213 root root 4096 2011-05-23 13:19 share


The code block looks pretty good:

while (<>) {
chomp; # strip record separator
printf "%5d : %s\n", $., $_;
}

NSA Operating Systems Security Configuration Guides

NSA published some rather interesting OS security guides:
http://www.nsa.gov/ia/guidance/security_configuration_guides/operating_systems.shtml

The RHEL Security Guides are quite good.

I've used these along with the Security Guide and the Security-Enhanced Linux guides from RHEL.

Friday, May 20, 2011

IBM SmartCloud Enterprise tips: LVM and FTPS

IBM SmartCloud Enterprise tips:

Learn how to set up a 64-bit Linux® instance (starting with a Bronze-level offering) with the Linux Logical Volume Manager (LVM), capture a private image and deploy a new instance as a different offering (a Platinum tier) and then grow the LVM volumes and file systems to accommodate the new physical volumes. This article also shows how to configure and manage LVM across physical volumes using Linux LVM-type partitions:


Set up a Microsoft® Windows™ Server 2008 R2 on the IBM Cloud so that it can act as a file server. This article details the steps to configure an FTPS and SMB file server using persistent storage; this enables the cloud user to upload and download files to and from instances in the cloud and facilitate data exchange: