别人编的简易网络词典

sh/bash/dash/ksh/zsh等Shell脚本
回复
20091157
帖子: 21
注册时间: 2010-03-01 11:51
送出感谢: 0
接收感谢: 0

别人编的简易网络词典

#1

帖子 20091157 » 2010-12-28 22:51

1 RGS=1
2 E_BADARGS=65
3
4 #prepare the cache dir to save the translate offline
5 if [ ! -e ~/dictionary ];
6 then
7 echo "make dir…."
8 mkdir ~/dictionary
9 fi
10
11 #check the arg that user inputed
12 if [ $# -ne "$ARGS" ];
13 then
14 echo "Usage:`basename $0` word"
15 exit $E_BADARGS
16 fi
17
18 if [ ! -f ~/dictionary/$1 ];
19 then
20 #read the translate from dict of baidu.com
21 #PS: Why to use Baidu? The answer is simple, fast.
22 w3m -no-cookie -dump 'http://dict.baidu.com/s?wd='$1' &f=#' | sed '/以下结果来自互联网网络释义/,$d'| sed '1,15d' | tac | sed '1,2d' | tac |sed -r '/^[0-9]+./N;s/n// ' > ~/dictionary/$1
23 fi
24
25 msg=`cat ~/dictionary/$1`
26 if [ "$msg" = "" ];
27 then
28 msg="您所查询的$1无法找到解释。"
29 fi
30 notify-send "$1" "$msg" >/dev/null 2>&1
31 if [ $? -eq 0 ];
32 then
33 exit 0
34 else
35
36 echo
37 echo -e "——————–33[1;40;33m $1 33[0m--------------------"
38 echo "$msg"
39 exit 0
40 fi
20091157
帖子: 21
注册时间: 2010-03-01 11:51
送出感谢: 0
接收感谢: 0

Re: 别人编的简易网络词典

#2

帖子 20091157 » 2010-12-28 22:54

不过有一些问题 改了一部分 另外的不知道怎么改了 麻烦大家帮忙~~
回复

回到 “Shell脚本”