|
|
发表于 2010-3-22 02:32:30
|
显示全部楼层
Post by zcg0696;2076845
安装chmlib然后执行以下命令
chm_http --port=8080 xxx.chm &
firefox localhost:8080
懒人用脚本:
#see if a right filename was given.
if [ -z "$1" ]
then
echo "Usage: chm.sh chm_filename."
exit 0
else
file="$1"
fi
if [ ! -e "$file" ]
then
echo "Can't find $file."
exit 0
#elif [ ! -f "$file" ]
#then
# echo "$file is not a regular file, can't open."
# exit 0
fi
if [ -z `file "$file" | grep 'MS Windows HtmlHelp Data'`]
then
echo "$file is not a chm file, can't open."
exit
fi
#see if there is a running chm_http, if true,
#find which ports it used and use a new port to open chm
#else specify port 8080
pids=`pidof chm_http`
if [ -z "$pids" ]
then
port=8080
else
chmlib_ports=`netstat -tlnp | grep 'chm_http' | awk '{print $4}' | awk -F ':' '{print $2}'`
for eachport in $chmlib_ports
do
last_used_port=$eachport
done
port=`expr $last_used_port + 1`
fi
chm_http --port=$port "$file" &
firefox localhost port
chm_http确实不错,以下是我的做法。
- #!/bin/bash
- for i in `seq 8000 8080`; do
- netstat -ntl | grep -q $i
- if [ $? -eq 1 ]; then
- port=$i
- break
- fi
- done
- echo "Listening port $port .."
- xdg-open http://localhost:$port &
- chm_http --port=$port --bind=127.0.0.1 "$1"
复制代码
先打开网址,趁浏览器还未起来马上运行chm_http,这样看了chm之后可以Ctrl-C中断掉。 |
|