《aix系统应用基础》.ppt_第1页
《aix系统应用基础》.ppt_第2页
《aix系统应用基础》.ppt_第3页
《aix系统应用基础》.ppt_第4页
《aix系统应用基础》.ppt_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.0 4.1 Unit 10 Processes Copyright IBM Corporation 2008 Unit Objectives After completing this unit, you should be able to: Define an AIX process Describe the relationship between parent and child processes Create and invoke shell scripts Copyright IBM Corporation 2008 The Process Environment ProgramUser and group ID Data 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 shell: $ echo $ 4712 lThe ps command shows the running processes: $ ps -u team01 Copyright IBM Corporation 2008 login: AIX System PID=202 -ksh login: john Johns Password: xxxxxx $ _ Environment program/usr/bin/ksh uidjohn gidstaff files/dev/tty1 PID202 Login Process Environment Copyright IBM Corporation 2008 AIX System $ cat kfile Environment during execution program/usr/bin/cat uidjohn gidstaff files/dev/tty1 kfile parent -ksh PID310 PPID202 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 and Children Copyright IBM Corporation 2008 $ x=4 $ ksh $ echo $x $ x=1 $ $ echo $x 4 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: 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 hello echo “Hello, John. Today is: $(date)“(1) pwd(2) ls(3) $ ksh hello Hello, John: 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 hello echo “Hello, John. Today is: $(date)“(1) pwd(2) ls(3) $ chmod +x hello $ hello Hello, 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_dir dir1=/tmp dir2=/usr $ . set_dir $ echo $dir1 /tmp $ echo $dir2 /usr . (dot): Execution in 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 2008 Exit Codes from Commands lA command returns an exit value to the parent process: 0 = Success 1 - 255 = Other than successful lThe environment variable $? contains the exit value of the last command: $ cd /etc/security ksh: /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 of 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 the command that is used to carry down the value of a variable into the subshell? export variable_name 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 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 2008 Shell Scripts 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) $ .scriptn

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论