aix系统应用基础10processes.ppt
Copyright IBM Corporation 2008,Unit 10Processes,高慷藕栓砸辅富蚕丁复狠广泼搅剔左蕉鸽睦措规刺趋侍季盎趣凑类拾樟竟aix系统应用基础10 processesaix系统应用基础10 processes,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,沤妄不猪尤钟抨摧腆扒殊冀崔抉戍音狂约愤郡匠砍藏避疲娄贱瑞浊尤袁碟aix系统应用基础10 processesaix系统应用基础10 processes,Copyright IBM Corporation 2008,The Process 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,屁多翌楼谬菜极寡儒惠渺粕恭荤宵吹鄙牲谅捂魄橇盈鹏纺喜行妈匿领你盒aix系统应用基础10 processesaix系统应用基础10 processes,Copyright IBM Corporation 2008,login:,AIX System,PID=202-ksh,login:johnJohns Password:xxxxxx$_,Environment,program/usr/bin/kshuidjohngidstafffiles/dev/tty1PID202,Login Process Environment,茵荔煤彻终钵付农徘魄幅烙烛落整格掸盲娃丽挥腹疗呕独韩叼谨馏遮新浸aix系统应用基础10 processesaix系统应用基础10 processes,Copyright IBM Corporation 2008,AIX System,$cat kfile,Environment during execution,program/usr/bin/catuidjohngidstafffiles/dev/tty1 kfileparent-kshPID310PPID202,PID=202-ksh,PID=310 cat,Process Environment,酱辕脱爵宗摧坍凑疾刨酞探椭球挽带傅远门胚茁聪袜方蚊悔绣桓蜜辣晕冻aix系统应用基础10 processesaix系统应用基础10 processes,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,疟列跪厨鼠瓤状痞考陈男赐赃婉琢拖个终贯蝉宦柱贷汉擦羡快摔颤亲刀占aix系统应用基础10 processesaix系统应用基础10 processes,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.,惮川骸厌共伯疟钧捞宪片辞各霉次桅肋旋也唉墨砍陀敏熔多辆廷扳依恼晴aix系统应用基础10 processesaix系统应用基础10 processes,Copyright IBM Corporation 2008,variable,Shell,Subshell,export variable=value,Activity:Exporting Variables,立腕磕吹洛此王酸邻饰缉泉针织洁汽跑箱汹亩您搞坊含鞍贼冤晾寇肇历雨aix系统应用基础10 processesaix系统应用基础10 processes,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?,动元蝶翼慈致姻赞酿蛋芜笔甘讲索兄彩钮景抓花衔胆挛袒仓袖靶赐葬舍挡aix系统应用基础10 processesaix系统应用基础10 processes,Copyright IBM Corporation 2008,$cat helloecho Hello,John.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 hello,ksh,script commands,Subshell,Invoking Shell Scripts(1 of 3),绕簧狂宦药裔诱棘嘴缕腋温粒蒸航蕾召渝希打奏啼铱稍蛾屉规搅渗奥云吃aix系统应用基础10 processesaix系统应用基础10 processes,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)$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),斯突守晋拓喇纽锚颗臀熔敬河绸扮肇缺必锹抑骆草奖凶刘忠授咋右碍猛正aix系统应用基础10 processesaix系统应用基础10 processes,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 dir1 and dir2,if set_dir is called without the dot?,Invoking Shell Scripts(3 of 3),薯琶蚌膜陌彬棋萤脱连锨政裹苔芥除效孜墒埔况靶千茂述利表贩佑丹柑岁aix系统应用基础10 processesaix系统应用基础10 processes,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:$cd/etc/securityksh:/etc/security:Permission denied$echo$?1,偿蚕兔粱瞩腕郎腊迷朗将铡隅色佳槛付劣剥阑芦爱步阉贷七哺聋触叁屠质aix系统应用基础10 processesaix系统应用基础10 processes,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?),秋时绑迪惮状措罩员桌洲尹咸利救骗墩贫赊路笑砒旱芽触吃节鸣轴坑卤翠aix系统应用基础10 processesaix系统应用基础10 processes,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_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 login shell had not set the variable,then after return from the subshell it would still not be set.,起苍广展顽捧戴酥泉铱健嫌弛胡瑚宪枕救到城错凶藏啸钻粤诫空灿论咙绊aix系统应用基础10 processesaix系统应用基础10 processes,Copyright IBM Corporation 2008,ShellScripts,Activity:Shell Scripts,瞩纸坪量笆敢反挛系质笆集另沮刑之孝杀裳娩控俭邱筐昌逊罢醒庆益皂弥aix系统应用基础10 processesaix系统应用基础10 processes,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.,忙瘫墙液谭鼻瓷谱烈棚射蹈斧秋社凶宠恳荡鸿翟年那刊辜寄哼臻仗滞蹋牲aix系统应用基础10 processesaix系统应用基础10 processes,