LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1234|回复: 17

谁能做一个脚本,功能如下:

[复制链接]
发表于 2004-5-23 13:42:16 | 显示全部楼层 |阅读模式
谁能做一个脚本,功能如下:
就是在用ping的时候,在丢包时让他能报警,其实在默认的情况下,只要在ping的后面加一个选项 -a 就能实现报警,不做他默认是在不丢包时报警,而在丢包时不报警的,我想做的是刚好相反的,谁能做这个??


另外还想问一下,这个pc喇叭报警的功能是在bash下用什么参数弄成的?也就是现在我想在bash下打个什么命令能让他响一下呀?

谢谢
发表于 2004-5-23 13:51:28 | 显示全部楼层
1,ping的选项里没有吗?
2,echo "\a"
 楼主| 发表于 2004-5-23 13:57:45 | 显示全部楼层
有吗?我怎么没有试出来呀?
发表于 2004-5-23 14:00:46 | 显示全部楼层
文本下 可以
 楼主| 发表于 2004-5-23 14:09:06 | 显示全部楼层
能告诉我如何做到吗?

我现在打ping www.163.com -a这种情况下,如果能ping通他就报警,如果不通他不报警。
我现在想的就是在不通的情况下报警,要怎么做?是哪个选项呀?
 楼主| 发表于 2004-5-23 14:20:09 | 显示全部楼层
我试了还是不行,在ping的功能里好象根本没有能在丢包时叫他报警的选项。
发表于 2004-5-23 14:23:23 | 显示全部楼层
  1. ping -c1 $1 >/dev/null
  2. case $? in
  3. 0)      echo "OK";;
  4. *)      echo "Warning!No conncet\a";;
  5. esac
复制代码
 楼主| 发表于 2004-5-23 14:36:04 | 显示全部楼层
要命,我刚才试了一下,发现在fc2下我的pc喇叭不管用了,我刚才试了一下ping加选项a也不响了我才知道是fc2下我的pc喇叭不管用了。

要在哪里将pc喇叭开启?
发表于 2004-5-23 15:01:31 | 显示全部楼层
/etc/inputrc
或者根据你用的终端来调整
 楼主| 发表于 2004-5-23 15:21:18 | 显示全部楼层
# do not bell on tab-completion
#set bell-style none
                                                                                
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
                                                                                
# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on
                                                                                
$if mode=emacs
                                                                                
# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
                                                                                
# for rxvt
"\e[8~": end-of-line
                                                                                
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
                                                                                
# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif

我的inputrc 文件要改哪里才能让pc喇叭好用?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表