shell写的CGI 提示502
本人想得到mini2440+linux的系统流量并以HTML显示出来,下面是代码:
可是一直提示502 bad getway 程序在没有写成CGI格式,在超级终端里是可以成功执行的 我本来怀疑是格式写错了
可是我最后拿了一个最简单的shellCGI打印Hello World 都还是502 这是怎么回事啊 。。。
#!/bin/sh
#
echo"Content-type:text/html"
echo""
echo"<html>"
echo"<head>"
echo"<title>net fiow</title>"
echo"</head><body>"
echo"<body bgcolor="6699FF">"
echo"<h1><font color="FFFFFF"><font color="black"><div align="center"><b>系统收发流量统计</b></font></font></h1>"
echo"<div align="center"><b>            接收    发送</b><br>"
typeset in in_old dif_in dif_in1 dif_out1 in_packet
typeset out out_old dif_out out_packet
in_old=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $1 }' )
out_old=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $9 }')
while true
do
in_packet=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $2 }' )
out_packet=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $10 }')
echo "字节数: ${in_old} bytes          ${out_old} bytes "
echo "包数: ${in_packet} packages          ${out_packet} packages "
sleep 1
in=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $1 }')
out=$(cat /proc/net/dev | grep eth0 | sed 's=^.*:==' | awk '{ print $9 }')
dif_in=$((in-in_old))
dif_in1=$((dif_in * 8 / 1024 / 1024 ))
dif_out=$((out-out_old))
echo "实时接收速率: ${dif_in} bytes <br>"
echo "实时发送速率: ${dif_out} bytes "
dif_out1=$((dif_out * 8 / 1024 / 1024 ))
# echo "IN: ${dif_in1} mbps OUT: ${dif_out1} mbps"
in_old=${in}
out_old=${out}
done
echo"</body>"
echo"</html>"
exit 0
[解决办法]
我的Web服务器是boa
[解决办法]
厉害啊,可惜我还是新手啊
[解决办法]
看日志信息!!!!!!!!!!!!!!!!1