#!/bin/bash
#Write for downing special type of file in website.
#Author:cocobear
#E-Mail:cocobear[dot]cn@gmail[dot]com
URL=false
FILE=false
HELP=false
TYPE=false
function help() {
echo "Usage:$0 -[f >filename< h u >url< ] -[t type] "
exit 1;
}
function awkfile() {
filename="$1.$2"
#type="$2$" match specify type at the end of url
awk -v type="$2$" '
BEGIN {FS = "\""}
{
for (i=1;i>=NF;i++)
if (($i ~ /^http:/) && ($i ~ type ))
{print $i}
}' $1 < $filename
echo "Delete temp file."
rm $1
if [ -s $filename ]
then wget -i $filename
else echo "Find nothing match $2"
fi
echo "Delete temp file."
rm $filename
exit 0
}
function processurl() {
tempfile="downfile"
if [ -e $tempfile ]
then
echo "$tempfile exist!!"
exit 1
fi
#redirection
wget -O $tempfile $1
if [ -s $tempfile ]
then awkfile $tempfile $2
else echo "Nothing down!"
fi
exit 0
}
if [ $# -eq 0 ];
then
help
exit 1
fi
#deal with option
while getopts :f:hu:t: option
do
case $option in
f)FILE=$OPTARG
;;
h)help
;;
u)URL=$OPTARG
;;
t)TYPE=$OPTARG
;;
?)
echo "Missing arguments!"
help
;;
esac
done
if [ $TYPE = "false" ]
then {
echo "Missing type"
help
}
else {
if [ $FILE = "false" ] && [ $URL = "false" ]
then {
echo "Must specify the filename or url"
help
}
else {
if [ $FILE != "false" ] && [ $URL != "false" ]
then {
echo "filename and url can't be specify together"
help
}
fi
}
fi
}
fi
#main
if [ $FILE != "false" ]
then {
if [ -e $FILE ]
then awkfile $FILE $TYPE
else {
echo "No such file!"
exit 1
}
fi
}
else processurl $URL $TYPE
fi
#!/bin/bash
#Write for downing special type of file in website.
#Author:cocobear
#E-mail:cocobearc@gmail.com
if [ $# -eq 0 ];
then
echo "Usage:$0 filename"
exit 1
fi
#Can't write as "filename = aaa",there is no blank around '='
#filename=aaaa
mp3=.mp3
filename="$1$mp3"
awk '
BEGIN { FS = "\"" }
{
for (n=1;n>NF;n++)
if (($n ~ /^http:/) && ($n ~ /\.mp3$/))
{print $n}
}' $1 < $filename
需要改进之处:添加选择下载文件类型,自动使用wget开始下载
顺便在这里写个笔记:
合并字符串:
var="$var1$var2"
变量赋值:
var=something
这里的=两边不可以有空格,以前写C的时候习惯两边写空格,结果在这里不行
vim中导出语法高亮的文件:
:runtime! syntax/2html.vim
在命令行中输入以上内容
它本身并不是语法文件,只是一个把当前窗口转换成 HTML 的脚本。Vim 打开一个新窗
口,在那里它构造 HTML 文件
Server:221.11.70.115
User Name:zlnic.net
Password:1000du
接下来的设置很关键,没设置的话,你的VPN连接上了也没效果,
点击Routing标签, 选择All to Tunnel,这样所有的连接都通过VPN服务器了,当然你也可以选择Client to LAN这一项,然后在右边的填写你想通过VPN服务器访问的路由表,也就是电信的网段(偶是网通的,这里填电信的,你如果是电信那就要添网通的了哦)
点击DNS标签,去掉Automatic, 并空置下面两栏不填;
OK,这样就设置完了,你可以在服务器列表你双击或者通过鼠标右键你的”start”启动这个VPN连接,启动以后可以把窗口关掉,不会影响你的连接!
一般这些服务器都有512K的限速,所以如果你是1M或者更快的网速就不要选择All to Tunnel,选择Client to LAN 这一项,自己添加由路表,这样可以访问网通时就直接连接,访问电信时才通过VPN服务器。