Category Scripts

How to Install GIT on AIX

Git

After a grueling battle trying to compile GIT from source on an AIX (6.1) machine, I thought I would try to save you some trouble and outline clearly what I had to do.  Please note I initially followed this guide, which gave me a good base, but I had to throw in a few extra tweaks.

First off, you will need to get the following dependencies.  I was able to get most of them from the IBM Linux Toolbox here, and the rest I got from the great people at Perzl.org

Dependencies:

bison-1.875-3.aix5.1.ppc.rpm
coreutils-5.2.1-2.aix5.1.ppc.rpm
expect-5.45-1.aix5.1.ppc.rpm
flex-2.5.4a-6.aix4.3.ppc.rpm
gcc-4.2.0-3.aix6.1.ppc.rpm
gcc-cplusplus-4.2.0-3.aix6.1.ppc.rpm
gdbm-1.8.3-5.aix5.2.ppc.rpm
gettext-0.10.40-8.aix5.2.ppc.rpm
git-git-5bc2dc2
git-git-v1.7.10.2-569-g5bc2dc2.zip
libXft-2.2.0-1.aix5.1.ppc...

Read More

AWK vs CUT

Well, not really.  But I assume I’ll get lots of attention with that name alone.  When I thought about writing this it was for one very specific thing only.

Often times in a script I’ll want to strip output based on a delimiter or columns.  I found myself constantly fighting with IFS and trying to make sense of delimiters that don’t follow a common pattern.  My two ways of extracting columns from a file/variable are as follows:

echo $variable | cut -f 2 -d “:” –> (-f to select column, -d to select delimiter)

echo $variable | awk ‘{ print $2 }’

Believe it or not, for someone that started off with no formal shell training or anything, this took me awhile to figure out.  Cut has its ups and downs but I will say this, awk is without a doubt worth learning.  In its entirety.

Anyways, th...

Read More

Quotation Marks

In shell scripting, you may run into a constant battle with quotation marks.  Seems silly, but between the three types (double quotes-”, single quotes-’, backticks-`), I have run into numerous problems that perhaps I can save you from.
First off, when copying any scripts, commands or data from the internet, if you run into any problems with code that is said to be tested, check the quotation marks.  Often times browsers, web themes or even copying and pasting can result into a mish-mash of punctuation changes.

Secondly, when nesting quotes in a script or command, be sure you a) alternate quotation styles when nesting and b) ensure your order of end-quoting matches.

A quick overview of meta characters is below.

Remember, anything in double quotes may be read by the shell interpreter and ...

Read More

Korn Shell (KSH) Command | if Test Parameters

if/Test Statement

test -e file
[ -e file ]
[[ -e file ]]

x=2
test $x -eq 1
[ $x -eq 2 ]
[[ $x -eq 3 ]]

File Test Operators

File status can be examined using several operators.

Parameter:     Meaning
-s file     size greater than zero
-r file      exists and is readable
-w file      exists and is writable
-x file      exists and is executable
-u file      exists and has the SUID bit set
-g file       exists and has the SGID bit set
-k file      exists and has the SVTX sticky bit set
-e file       exists
-f file      exists and is an ordinary file
-d file      exists and is a directory
-c file      exists as a character special file
-b file      exists and is a named pipe file
-p file      exists and is a named pipe file
-L file    ...

Read More

FTP Script | AIX to Windows Share

Often times you may want to create a script to copy, move or grab files from your AIX machine to a Windows (or other) box.  In some cases, there may a shared Windows drive created office wide and you would like to dump system information or reporting here.  If ssh is not supported on the other end, you will need to use FTP.

General FTP Commands

Here is a quick script to move files from your AIX box to your Windows share.

ftpmove(){

ftp -n <<-EOF
open fully_qualified_server_name
user username password
cd path/to/file
put file_to_copy_to_windows

get file_to_copy_to_aix

EOF
}

ftpmove

Read More

mksysb Script to Catch Errors and Report Problems

mksysb

Here is a mksysb script I came up with in order to catch any errors and include all data on the lpar.  This is set up to retry the mksysb if it gets an error.  If the command continues to receive errors it will send out an email letting you know.  I have seen a lot of problems with the deletion of temp files and the lpar running out of memory and failing.  From all of my testing this script catches most of these problems

#!/usr/bin/ksh

DATE=`/usr/bin/date +"%y%m%d"`
HOST=`/usr/bin/hostname`
ERROR=/tmp/sysb1.err...
Read More