📄 ex44.sh
字号:
#!/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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -