ex44.sh
来自「Shall高级编程」· Shell 代码 · 共 34 行
SH
34 行
#!/bin/bash# Killing ppp to force a log-off.# Script should be run as root user.killppp="eval kill -9 `ps ax | awk '/ppp/ { print $1 }'`"# -------- process ID of ppp ------- $killppp # This variable is now a command.# The following operations must be done as root user.chmod 666 /dev/ttyS3 # Restore read+write permissions, or else what?# Since doing a SIGKILL on ppp changed the permissions on the serial port,#+ we restore permissions to previous state.rm /var/lock/LCK..ttyS3 # Remove the serial port lock file. Why?# Note:# Depending on the hardware and even the kernel version,#+ the modem port on your machine may be different --#+ /dev/ttyS1 or /dev/ttyS2.exit 0# Exercises:# ---------# 1) Have script check whether root user is invoking it.# 2) Do a check on whether the process to be killed#+ is actually running before attempting to kill it. # 3) Write an alternate version of this script based on 'fuser':#+ if [ fuser -s /dev/modem ]; then . . .
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?