《《aix系统应用基础》.ppt》由会员分享,可在线阅读,更多相关《《aix系统应用基础》.ppt(17页珍藏版)》请在三一办公上搜索。
1、 Copyright IBM Corporation 2008,Unit 10Processes,Copyright IBM Corporation 2008,Unit Objectives,After completing this unit,you should be able to:Define an AIX processDescribe the relationship between parent and child processesCreate and invoke shell scripts,Copyright IBM Corporation 2008,The Process
2、 Environment,ProgramUser and group IDData Process ID(PID)Open filesParent Process ID(PPID)Current directoryProgram variables,What Is a Process?,Each program runs in a process:The variable$shows the process ID of the current shell:$echo$4712The ps command shows the running processes:$ps-u team01,Copy
3、right IBM Corporation 2008,login:,AIX System,PID=202-ksh,login:johnJohns Password:xxxxxx$_,Environment,program/usr/bin/kshuidjohngidstafffiles/dev/tty1PID202,Login Process Environment,Copyright IBM Corporation 2008,AIX System,$cat kfile,Environment during execution,program/usr/bin/catuidjohngidstaff
4、files/dev/tty1 kfileparent-kshPID310PPID202,PID=202-ksh,PID=310 cat,Process Environment,Copyright IBM Corporation 2008,$echo$202$ksh(Create a subshell)$echo$206$date(Run a command)Tue Jan 4 11:18:26 GMT 2000$(Exit the subshell)$echo$202,Subshell,PID PPID-ksh 202 1 ksh 206 202 date 208 206,Parents an
5、d Children,Copyright IBM Corporation 2008,$x=4$ksh$echo$x$x=1$echo$x4,Subshell,Variables and Processes,Variables are part of the process environment.Processes cannot access or change variables from another process.,Copyright IBM Corporation 2008,variable,Shell,Subshell,export variable=value,Activity
6、:Exporting Variables,Copyright IBM Corporation 2008,A shell script is a collection of commands stored in a text file,$vi hello echo Hello,John.Today is:$(date)pwd ls:wq$,What Is a Shell Script?,Copyright IBM Corporation 2008,$cat helloecho Hello,John.Today is:$(date)(1)pwd(2)ls(3)$ksh helloHello,Joh
7、n:Today is:Wed Sep 13 19:34(1)/home/john(2)books letter1 text2sarah(3)$_,-ksh,$ksh hello,ksh,script commands,Subshell,Invoking Shell Scripts(1 of 3),Copyright IBM Corporation 2008,The shell uses the PATH variable to find executable programs.,$cat helloecho Hello,John.Today is:$(date)(1)pwd(2)ls(3)$c
8、hmod+x hello$helloHello,John:Today is:Wed Sep 13 19:34(1)/home/john(2)books letter1 text2sarah(3)$_,Subshell,Invoking Shell Scripts(2 of 3),Copyright IBM Corporation 2008,$cat set_dirdir1=/tmp dir2=/usr$.set_dir$echo$dir1/tmp$echo$dir2/usr,.(dot):Execution in the current shell,?,What is the value of
9、 dir1 and dir2,if set_dir is called without the dot?,Invoking Shell Scripts(3 of 3),Copyright IBM Corporation 2008,Exit Codes from Commands,A command returns an exit value to the parent process:0=Success 1-255=Other than successfulThe environment variable$?contains the exit value of the last command
10、:$cd/etc/securityksh:/etc/security:Permission denied$echo$?1,Copyright IBM Corporation 2008,Checkpoint,When would you execute a shell script using the dot(.)notation?Why?What is the command that is used to carry down the value of a variable into the subshell?What would be the value of x at the end o
11、f the following steps?$(.login shell.)$ksh$x=50$export x$(what is the value of x set to now?),Copyright IBM Corporation 2008,Checkpoint Solutions,When would you execute a shell script using the dot(.)notation?Why?When you are using the script to change variable values in the current shell.What is th
12、e command that is used to carry down the value of a variable into the subshell?export variable_nameWhat would be the value of x at the end of the following steps?$(.login shell.)$ksh$x=50$export x$(what is the value of x set to now?)x would have the value it had before starting the subshell.If the l
13、ogin shell had not set the variable,then after return from the subshell it would still not be set.,Copyright IBM Corporation 2008,ShellScripts,Activity:Shell Scripts,Copyright IBM Corporation 2008,Unit Summary,Shell scripts can be invoked in three ways:$ksh scriptname(must have read permission)$scriptname(must have read and execute permission)$.scriptname(must have read permission)Each program runs in an AIX process.Every process has an environment in which it runs much of which is inherited from its initiating process,the parent process.,
链接地址:https://www.31ppt.com/p-5896017.html