《《aix系统应用基础》.ppt》由会员分享,可在线阅读,更多相关《《aix系统应用基础》.ppt(17页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Course materials may not be reproduced in whole or in part without the prior written permission of IBM.5.04.1 Unit 10Processes Copyright IBM Corporation 2008Unit ObjectivesAfter completing this unit,you should be able to:Define an AIX processDescribe the relationship between parent and child process
2、esCreate and invoke shell scripts Copyright IBM Corporation 2008The Process EnvironmentProgramUser and group IDData Process ID(PID)Open filesParent Process ID(PPID)Current directoryProgram variables What Is a Process?lEach program runs in a process:lThe variable$shows the process ID of the current s
3、hell:$echo$4712lThe ps command shows the running processes:$ps-u team01 Copyright IBM Corporation 2008login:AIX SystemPID=202 -kshlogin:johnJohns Password:xxxxxx$_Environmentprogram/usr/bin/kshuidjohngidstafffiles/dev/tty1PID202Login Process Environment Copyright IBM Corporation 2008AIX System$cat k
4、fileEnvironment during executionprogram/usr/bin/catuidjohngidstafffiles/dev/tty1 kfileparent -kshPID310PPID202PID=202 -kshPID=310 catProcess 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$20
5、2 Subshell PID PPID -ksh 202 1 ksh 206 202 date 208 206Parents and Children Copyright IBM Corporation 2008$x=4$ksh$echo$x$x=1$echo$x4 Subshell Variables and ProcessesVariables are part of the process environment.Processes cannot access or change variables from another process.Copyright IBM Corporati
6、on 2008variableShellSubshellexport variable=valueActivity:Exporting Variables Copyright IBM Corporation 2008A 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,Jo
7、hn.Today is:$(date)(1)pwd(2)ls(3)$ksh helloHello,John:Today is:Wed Sep 13 19:34(1)/home/john(2)books letter1 text2sarah(3)$_-ksh$ksh hellokshscript commands Subshell Invoking Shell Scripts(1 of 3)Copyright IBM Corporation 2008The shell uses the PATH variable to find executable programs.$cat helloech
8、o Hello,John.Today is:$(date)(1)pwd(2)ls(3)$chmod+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 i
9、n the current shell?What is the value of dir1 and dir2,if set_dir is called without the dot?Invoking Shell Scripts(3 of 3)Copyright IBM Corporation 2008Exit Codes from CommandslA command returns an exit value to the parent process:0=Success 1-255=Other than successfullThe environment variable$?conta
10、ins the exit value of the last command:$cd/etc/securityksh:/etc/security:Permission denied$echo$?1 Copyright IBM Corporation 2008Checkpoint1.When would you execute a shell script using the dot(.)notation?Why?2.What is the command that is used to carry down the value of a variable into the subshell?3
11、.What 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?)Copyright IBM Corporation 2008Checkpoint Solutions1.When would you execute a shell script using the dot(.)notation?Why?When you are using the script to change variab
12、le values in the current shell.2.What is the command that is used to carry down the value of a variable into the subshell?export variable_name3.What 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
13、 it had before starting the subshell.If the login shell had not set the variable,then after return from the subshell it would still not be set.Copyright IBM Corporation 2008ShellScriptsActivity:Shell Scripts Copyright IBM Corporation 2008Unit SummaryShell scripts can be invoked in three ways:$ksh sc
14、riptname(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.Copyright IBM Corporation 2008