You are on page 1of 5

AIX for System Administrators Page 1 of 5

Compartir 0 Más Siguiente blog» Crear blog Acceder

AIX for System Administrators


Practical Guide to AIX

...any feedback are highly welcome: aix4adm@gmail.com

ABOUT FS - LVM GENERAL HACMP - POWERHA HMC - ISD NETWORK NIM PERFORMANCE STORAGE UPDATE - INSTALL VIO +EXTR
AS

SCRIPT:

SEARCH ON THIS BLOG:

KORN SHELL:
http://www.bolthole.com/solaris/ksh.html
http://www.well.ox.ac.uk/~johnb/comp/unix/ksh.html

PAGEVIEWS

SYMBOLS:
#!/usr/bin/ksh <--this indicates the shell, which should be used to interpret the script
1,042,127
' ' <--ignores all metacharacters between the quotes (echo '$HOME' --> $HOME) (with ssh variables are interpreted)
z ABOUT
" " <--ignores all metacharacters except for $, ` and \ (echo "$HOME" --> /home/root) (with ssh everything is string-
literal)
\ <--ignores the special meaning of the following character (echo \$HOME --> $HOME) FS - LVM
(it is the continuation character as well, to continue a command in a new line)
${VAR}hello <--{} distingueshes the variable from the surrounding text z FS

~ <-- represents the home directory of the user (~joe refer's to the home dir of joe) z LV

------------------------------------ z Mirror
x=day z PV
echo there is a ${x}long meeting <--{} is used to eliminate the need of space after the variable z VG
there is a daylong meeting
------------------------------------
x=`date` or x=$(date) <-() is supported only in ksh GENERAL
------------------------------------
z AIX History

z Backup
arithmeic:
z Commands
(( x += 1 )) <- counter adds 1 to x
z CPU
(( x -= 1 )) <- counter minus 1 from x
x=$(($x+1)) <- counter adds 1 to x z Crontab
z Date
let command can be used for this as well (+,-,*,/): z Devices
let x=x+10 z Dump
let x=x/2 z Errpt
Syslogd
read <variable> <- reads from the input to the given variable z Firmware
export variable=value <- passes variable into a subshell z IO

z Memory
set -x <- shows real time info for debugging
z ODM
set -u <- unsets variables
z Printing

z SRC
test command:
z Startup
The test command evaluates the expression and returns a return code 0 if true.
test expression or [ expression ] or [[ expression ]] (leave a space near the squaer braces) z System

In newer Korn shell the modern notation [[...]] is used, which is an extension of the test command. z Tunables
z User
integer operations: z User
if [ $? -eq 0 ] ; then <- equal
if [[ $? -eq 1 ]] <- [[ is for test condition
if [ $? -ne 0 ] ; then <- not equal HACMP
if [ $? -lt 0 ] ; then <- less than z Appl.
if [ $? -gt 0 ] ; then <- greater than
z Basics
if [ $? -le 0 ] ; then <- less equal
z Build
if [ $? -ge 0 ] ; then <- greater equal
z Clverify
$number1 -eq $number2 <- numbers are equal
$number1 -ne $number2 <- numbers are not equal z Commands
z Config

string operations: z DARE


$string1 = $string2 <- strings are identical z Disk
$string1 != $string2 <- strings are not identical z Storage

if [[ -e $FILE ]] <- if file exist


HMC -
read command:
z ASMI
It reads one line from standard input and assigns the values of each field to a shell variable.

http://aix4admins.blogspot.com/2011/09/korn-shell-httpwww.html 9/27/2013
AIX for System Administrators Page 2 of 5

print command (printf): z HMC

printf '%20s\n' "-- PLAYER --" z HMC

z HMC/P7
The syntax is %[-]m[.n]s z ISD
%s is the string, [-] is left justified, m is no. of chars wide, [n] is print the first n chars of the string. z RMC
The above example shows the string “- PLAYER -” printed, right justified in string wide of 20 chars.

VAR1="Hello" NETWORK
VAR2="Worldddd"
z Basics
Routing
printf '%10s %-10.5s\n' $VAR1 $VAR2 z Basics
Hello World Subnet
z Basics
---------------------- z Commands

z Eth.
RUNNIG A SCRIPT:
z Ethernet

z IVE
Each shell script is executed in a subshell. Variables defined in a shell script cannot be passed back to the parent shell.
z Netcd

. <---if you invoke a shell script with a . (dot) it runs in the current shell. z NFS

Variables defined in this script are defined also for the current shell. z RSH

z Sendmail
./ <- refers to files in the current working directory z SSH
~ <- refers to the home directory z SSH

z Telnet
3 ways of running a script:
ksh scriptname (read permission needed)
scriptname (read and execute permission needed)(in the PATH variable must be defined the dir) NIM
. scriptname (read permission needed) (it runs in the current shell, a subshell will not be invoked)
z Basics
z Bootpd

$$ process id z Install

$0 shell script name currently executing z LPP

$1, $2 ... parameters which were invoked with the script z Machines
$* equal all arguments passed z MKSYSB
$# number of arguments passed into shell script (if [[ $# -ne 1 ]]...) z Nimadm
$? retrurn code of last command executed z SPOT
command1 && command2 if command1 successful then do command2 (ls s* && rm s*) (if [[ $ACE = "HIGH" && $banker_score -ge 11 ]])
command1 || command2 if command1 not successful then do command2 ( if [[ $ACE = "HIGH" || $banker_score -ge 11 ]])
PERFORMANCE
exit n pass a return code to shell script
z Basics
$! process ID of last background process
z CPU
z I/O
true this command always returns a true result
false this command always returns a false result z iostat
z Memory

-------------------------------------------------- z Network
z svmon
LOOPS: z topas

z vmstat
for i in `cat file`
z VMM
do
z VIO
...
done
STORAGE

for i in /tmp/* it will remove all files in /tmp z Adapter

do z Basics

rm $i z Basics
done z EMC
z Hitachi
while [[ $x -lt 9 ]] z HP EVA
do z MPIO
...
z SDD
done

UPDATE
read game?"Another Game (y|n)? "
z Basics
case $game in
y|Y) :;; <- ":" means continue z Commands

n|N) EXT=1;; z IFIX

esac

VIO

-------------------------------------------------- z Basics

z Commands
CASE: z AME
(it can happen that there is a problem with numerical variable so this is needed before the CASE condition: "x=echo $x")
z CDROM

z LPM
case $x in
z NIB
1 )
echo z NPIV

;; z SEA

http://aix4admins.blogspot.com/2011/09/korn-shell-httpwww.html 9/27/2013
AIX for System Administrators Page 3 of 5

2 )
echo "Stopping the ovo agent..." z Shared

;; z VIOS

z Virt.
* ) z Virt.
echo "bye" z VSCSI
;; z VSCSI
esac

-------------------------------------------------- +EXTRAS

z +others
TIPS & TRICKS:
z alt_disk

cat <file> | head -n $x | tail -1 <-displays a line from a file z awk

awk 'NR==2' /root/settitle <--displays the 2nd line in the file:/root/setitle z bash

/usr/bin/echo yes | command <-- input is automatically yes z citrix


echo "$FS2:\t it is mounted now" <--\t will do a tab in the output z java
perl -e 'select(undef,undef,undef,.3)' <--it will sleep for 0.3 second z kdb
z ksh
---------------------
z locale
z multibos
Run the script every 2nd Sunday of the month:
z perl
DAY=$(date "+%d")
z profiles
[ $DAY -ge 8 -a $DAY -le 14 ] || exit <- if $DAY greater than 8 and lesser than 14 the script will continue
...rest of the script if not (|| means condition is false) it will exit z rbac
z Rsh

z samba
it will check if a file older than a week and if yes, delete it: z screen
35 21 * * 0 /usr/bin/find /home/traffic/ -name "trace" -mtime +7 -exec /usr/bin/rm {} \\; z script

z sudo
z vi
leaving the cursor at the same position while counting:
x=1
while [[ $x -le 100 ]]; do
tput cub 20
print -n $x
(( x += 1 )
done

Labels: +EXTRAS

No comments:
Post a Comment

Comment as: Select profile...

Publish Preview

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

Template images by Storman. Powered by Blogger.

http://aix4admins.blogspot.com/2011/09/korn-shell-httpwww.html 9/27/2013
AIX for System Administrators Page 4 of 5

http://aix4admins.blogspot.com/2011/09/korn-shell-httpwww.html 9/27/2013
AIX for System Administrators Page 5 of 5

http://aix4admins.blogspot.com/2011/09/korn-shell-httpwww.html 9/27/2013

You might also like