




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度金融行业职业卫生培训计划
- 2025至2030中国自行车架行业市场占有率及投资前景评估规划报告
- 2025至2030中国自动称重机行业市场占有率及投资前景评估规划报告
- 2025至2030中国自动收费(AFC)车站设备行业发展趋势分析与未来投资战略咨询研究报告
- 2025至2030中国自动售水机行业消费动态与需求策略研究报告
- 2025至2030中国自动助理电话系统行业市场占有率及投资前景评估规划报告
- 2025至2030中国脱水蔬菜烘干机行业市场深度研究及发展前景投资可行性分析报告
- 2025至2030中国胸腔引流导管行业市场占有率及投资前景评估规划报告
- 2025至2030中国聚氨酯胶行业市场发展分析及发展趋势与投资前景预测报告
- 2025至2030中国羊毛针织纱行业产业运行态势及投资规划深度研究报告
- 中国古代文化常识(上)
- 礼品礼金登记表
- 【新】2019-2020成都市石室中学北湖校区初升高自主招生数学【4套】模拟试卷【含解析】
- 《文明礼貌我最棒》班会课件
- 意外受伤赔偿协议书的格式
- PE管闭水试验表
- 山东省教师职称改革实施方案
- 《河南省企业安全风险辨识管控与隐患排查治理双重预防体系建设导则(试用)》
- 生产过程检验记录表
- 规划放线报告材料样本
- 完整版佛教葬礼仪式
评论
0/150
提交评论