课程: Learning Linux Shell Scripting
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Watching a process
- [Instructor] You can have your scripts watch other processes and message when they terminate. Let's learn how to do that. From the terminal, touch proc.sh and let's do a change mode 755 proc.sh and atom proc.sh. Got user forward slash bin forward slash env space bash and we're gonna create a variable called status and we're just gonna give it an initial value of zero. Status equals zero. Again we're gonna check to make sure that we got a parameter passed to us, so we'll say if square brackets space minus Z, and we'll say dollar sign one, and that's our input parameter if it's empty. Then we're gonna say then echo please supply a process which is PID, a process ID. And then exit with a one. And we got the fi, now this time we're gonna do a while loop but it's gonna be a little different than before 'cause we're gonna wait for this value to change. So we're gonna say while square brackets space dollar sign status is equal to zero. And we're gonna do and done. And the PS command lists…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。