免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: gao_linfeng
打印 上一主题 下一主题

今天是我女儿的1周岁生日,发个脚本,这个能让pc喇叭实现按键发音 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2008-08-06 12:18 |只看该作者
祝她生日快乐!

论坛徽章:
0
12 [报告]
发表于 2008-08-06 12:41 |只看该作者

回复 #10 可可熊 的帖子

没有,我上面两个脚本就算是配置文件了呀,我这个是bash脚本做的,所以效率肯定不算高,就是没事拿来玩玩吧。
另外有的时候机器上没有音箱,但还想听个音乐什么的,就自己编个简谱然后自已听吧。呵呵

再送几个简谱文件:
###################
1 35 5 6 5  3 15553 1 tttttt 1  t1 111tyu1 1 31235 5 3313532 2  6 5 2 3 53 53231 3  ty113355222y2  t1 13 35 135565 3155531 t 1 3155531 t 1 5 8 5 8 8
###################
1  23 13 1 3  2 344324  3 45 35 3 5  4  566546   5 123456  6 234567  7 345678 876 4 7 5 8 5 3 2 1  23 13 1 3  2 344324  3 45 35 3 5  4  566546   5 123456  6 234567  7 345678 876 4 7 5 8  12345678  5  8
###################
y123 5 312y 1235 5 623 356  5 6876563 123  51 y 12365 3 6 6543 2 3 5y12 123 55 6 8 76536
###################
t321t ttt321y yy432u u55423 1tt321t tt321y yy432555565421  333 333 35123 4444433 33212 5 333 333 35123 4444433 55421
###################
e t y1 2y1t 5 865352  2 3u y ty12 e1yty1t  35u2y1t ete tyu2y ty1  253232 1yte  1 y1ytety1t
###################
3 3 4 5 5 4 3 2 1 1 2 3 3  22  3 3 4 5 5 4 3 2 1 1 2 3 2  11   2 2 3 1 2 343 1 2 343 2 1 2 t 3  3 4 5 5 4 3 421 1 2 3 2  11
###################
556 5 8 7  556 5 9 8   55= 0 8 7 6   --0 8 9 8
###################
5  35 8  6 8 5  5 123 212   5 358 7 6 8 5  5 234 u 1  6 8 8  7678  67866531 2  5 3587 6 8 5  5 234  u 1
###################
t 1  113 2  123 1  135 6   6 5  3312  12 3 1  yyt 1   6 5  331 2  12 6 5  335 6   8 5  331 2  12 3 1  yyt 1
###################
ty1 53 23  ty1 52 12  356  351 32uy  2 322uyt  568 68  387 67  632  376 5  568 68  387 67  632 35 22y1

论坛徽章:
0
13 [报告]
发表于 2008-08-06 12:42 |只看该作者
祝你女儿生日快乐,健康快乐成长

论坛徽章:
0
14 [报告]
发表于 2008-08-06 12:50 |只看该作者
再发个脚本,这个可以实现ping的效果显示为cisco路由器的那种方式


#!/bin/bash
#本程序用以实现ping一个地址,但显示方式为cisco类似的方式.
trap exitprocess INT

####################################################
function exitprocess()
{
  echo -en "\n\e[43;1m 确认退出吗? [y/N] \e[0m"
  read -n1 dd
  echo
  if test $dd = y 2>/dev/null || test $dd = Y 2>/dev/null ;then
     exit
  fi
}
####################################################

x=0
y=0
read -p " 请在下面输入IP地址 (默认: 202.96.64.6: " a
read -p " 请输入要ping包的个数 (默认: 100个): " b
echo -e "\n\e[44;1m 正在对 ${a:=202.96.64.68} 进行ping测试. \e[0m\n"
for ((i=0;i<${b:=100};i++)) ; do
    if  ping -c1 ${a:=202.96.64.68} -i 0.3 1>/dev/null 2>/dev/null ;then
        echo -en '\e[32;1m!\e[0m'
        ((x++))
    else
        echo -en '\e[31;1m.\e[0m\a'
        ((y++))
    fi
done
echo -e "\n\e[33;1m 共发送 $i 个包, 接收 $x 个包, 丢弃 $y 个包, 丢包率为 $(($y*1
00/$i))% \e[0m\n"
read -s -p "测试完毕,按回车键继续... "
echo
exit

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
15 [报告]
发表于 2008-08-06 12:51 |只看该作者
Happy Birthday!

论坛徽章:
0
16 [报告]
发表于 2008-08-06 13:04 |只看该作者
再发个脚本,这个可以实现对某个ip实现进行ping,还可以选择ping通或者ping不通时的报警音量,比如你正在对某个ip进行ping,想在丢包时发出报警,你就可以把ping通时报警音量设置为1,ping不通时为900.
注意: 本脚本需要用到beep和figlet两个软件.


#!/bin/bash
#本程序用以实时监测某个网络地址的ping通状况.
trap exitprocess INT

####################################################
function exitprocess()
{
  echo -en "\n\e[43;1m 确认退出吗? [y/N] \e[0m"
  read -n1 dd
  echo
  if test $dd = y 2>/dev/null || test $dd = Y 2>/dev/null ;then
     exit
  else
     return
  fi
}
####################################################

echo -e "\n        \e[44;1m*******************************************************\e[0m        "
echo -e "        \e[44;1m***   本程序用以实时监测某个网络地址的ping通状况!   ***\e[0m        "
echo -e "        \e[44;1m*******************************************************\e[0m        \n"
read -p " 请输入一个有效的网络地址 (默认: 202.96.64.6: " ipa
read -p " 请输入ping通时的报警音量 (输入值在1-19999之间,默认: 1Hz): " beepaumix1
read -p " 请输入ping不通时的报警音量 (输入值在1-19999之间,默认: 900Hz): " beepaumix2
ipb=${ipa:=202.96.64.68}
clear
echo -e "\e[32;1m$(figlet Now testing\ .\ .\ .  Please wait\ \!)\e[0m"
echo -e "\e[35;1m  正在监测 $ipb ,退出请按\e[31;1m< Ctrl+c >\e[35;1m键! \e[0m\n"
while : ;do
  if (! ping -c1 $ipb 1>/dev/null 2>/dev/null) ;then
     echo -en "\e[44;37;1m [$(date|awk '{print $5}')]  网络地址: $ipb -----> \e[41;37;1m 断开! \e[0m                           "
     echo -en "\r"
     beep -f ${beepaumix2:=900} -r 3 -l 200 1>/dev/null 2>/dev/null
     ((i++))
  else
     echo -en "\e[44;37;1m [$(date|awk '{print $5}')]  网络地址: $ipb -----> \e[42;37;1m 己通! \e[0m                           "
     echo -en "\r"
     beep -f ${beepaumix1:=1} -l 300 1>/dev/null 2>/dev/null
  fi
  sleep 0.5s
done

[ 本帖最后由 gao_linfeng 于 2008-8-12 08:34 编辑 ]

论坛徽章:
0
17 [报告]
发表于 2008-08-06 13:08 |只看该作者
祝贺:

论坛徽章:
0
18 [报告]
发表于 2008-08-06 17:11 |只看该作者
说到ping,说一下ping的一个很好玩而且好用的功能ping -f +ip
要root权限,动态显示主机和你的ping值。
如果你ping -f +ip >a.log的话,用vi打开,一般会是这样:
......^H.^H.^H.^H^H.^H..^H.^H^H.^H^H..^H
附man:
-f     Flood ping. For every ECHO_REQUEST sent a period ‘‘.’’ is printed, while for  ever  ECHO_REPLY
              received  a backspace is printed.  This provides a rapid display of how many packets are being
              dropped.  If interval is not given, it sets interval to zero and outputs packets  as  fast  as
              they  come  back  or one hundred times per second, whichever is more.  Only the super-user may
              use this option with zero interval.

论坛徽章:
0
19 [报告]
发表于 2008-08-06 17:26 |只看该作者

回复 #18 walkerxk 的帖子

man fping

fping  is  a  like  program which uses the Internet Control Message Protocol (ICMP) echo request to determine if a target
       host is responding.  fping differs from ping in that you can specify any number of targets on the command line, or  spec-
       ify a file containing the lists of targets to ping. Instead of sending to one target until it times out or replies, fping
       will send out a ping packet and move on to the next target in a round-robin fashion.

论坛徽章:
0
20 [报告]
发表于 2008-08-06 21:24 |只看该作者
呵呵。
祝你女儿生日快乐。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP