已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2022年黔西市“特岗计划”招聘考试试题及答案
- 2022年江西省“三支一扶”计划招募岗位信息表考试试题及答案
- 2022年广东深圳实验学校选聘教师考试试题及答案
- 应用统计:时间序列分析
- C证6露天煤矿爆破试题及答案
- 销售业务述职报告
- 省内竞赛题库(医疗卫生专业-笔试B卷)
- 2024春高中地理区域地理第3篇中国地理第4单元中国地理概况第6课时中国的农业课前预习
- 2024八年级地理下册第五章我国的地域差异第2课时北方地区和南方地区习题课件晋教版
- 2024年酰卤项目营销方案
- 办公室玻璃隔断施工方案
- 【幼儿园班本课程研究文献综述4100字(论文)】
- 加纳光伏发电项目市场投资前景预测报告
- 部编版五年级语文下册《手指》评课稿
- 汽车底盘构造与维修课程介绍
- 某二级医院财务科13种岗位说明书
- 第8课+見方を変える+第三课时课件【小语种日语精讲精研】人教版初中日语八年级
- 2023版押品考试题库必考点含答案
- 2023年湖南长沙市特殊教育学校招考聘用教师笔试题库含答案解析
- 临沂青少示范性综合实践基地运行方案
- 高级烟叶制丝操作工理论考试复习题库大全-2判断题汇总
评论
0/150
提交评论