AIX 5L Basics (Unit 10) – Processes

Everything runs in a process

Process Environment:
program /usr/bin/cat
uid (user id) wltest
gid (group id) staff
files (file being catted) /dev/tty1 (terminal)
parent -ksh
pid (process id) 210
ppid (parent process id) 202

Others include: data, open files, current dir and program variables

echo $$ – shows the process of the current shell
ps -u wltest – shows the processes for the user wltest

getty process
init process – PID 1 – etc/inittab – Initial process started when booting the system

x = 4
export x – passes values down to child processes

Note: Only parent processes can pass down variable values. Child processes cannot pass variable values up to parents.

Shell Scripts:
A collection of commands stored in a text file

vi hello
echo “Hello, Wayne. Today is: $(date)”

Executing Scripts:
1. Use a new shell (ei. ksh hello)
2. Add execute permission (ei. chmod +x hello = chmod a+x hello)

Note: The shell uses the PATH variable to find and execute programs.

Invoking Shell Scripts:
cat set_dir

ksh set_dir – runs in a sub(child) process and then is deleted
. set_dir – runs in the current shell environment
.(dot): Executes in the current shell environment, doesn’t create a child

The Meaning of Dots:
. ./.profile
dot1 – run in the current shell
dot2 – current directory
dot3 – hidden file

Exit Codes:
0 – Success
1-255 – Failed for some reason

echo $? – contains the exit value of the last command

cd /etc/security
ksh: /etc/security: Permission Denied

echo $?

ls | tee file | wc -l – only checks last exit code

Leave a Reply

Your email address will not be published. Required fields are marked *