shell scripting- monitor error

shell scripting- monitor error

[code:1]
stp=3
until [ $stp = 0 ]
do
ifconfig eth1 | sed -n '2p;5p;6p;8p' >> log

p1=$(tail -11 log | sed -n '4p' | awk '{print $6}' | awk -F: '{print $2}')
p2=$(tail log | sed -n '10p' | awk '{print $6}' | awk -F: '{print $2}')

p3=$((($p2 - $p1)/2))
echo $p3 "bytes per-second downloading" >> log


date >> log
echo '-------------------------------------------------------' >> log
tail -7 log
sleep 2
done
[/code:1]

this script monitors a NIC on the computer, refreshes every 2 sec. write the resualt into a log file with time appended
it also caculated the download speed in the last 2 sec of the computer

it is a very simple script
any comments about make it better or more useful?

thanks
it's good.
$ p3=$((($p2 - $p1)/2))
bash: ( - )/2: syntax error: operand expected (error token is ")/2")
OS?
并不是那个计算式有问题,而已脚本执行到那步出了问题
看了一下是$p1 $p2 为空

不过我的log就一点点内容
druggo@ypg ~/tmp $ cat log
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          collisions:0 txqueuelen:1000
          RX bytes:241423087 (230.2 Mb)  TX bytes:16744844 (15.9 Mb)

druggo@ypg ~/tmp $
我 执行没有问题!
[quote:4c48d3c58a="druggo"]并不是那个计算式有问题,而已脚本执行到那步出了问题
看了一下是$p1 $p2 为空

不过我的log就一点点内容
druggo@ypg ~/tmp $ cat log
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          collisions:0 txqueuelen:1000
          RX bytes:241423087 (230.2 Mb)  TX bytes:16744844 (15.9 Mb)

druggo@ypg ~/tmp $[/quote]

may i have your ifconfig 's output layout?
[code:1]
/sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:8D:7B:8F:78
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:60197 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93168 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4816911 (4.5 Mb)  TX bytes:131787232 (125.6 Mb)
          Interrupt:23 Base address:0xe000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:325 errors:0 dropped:0 overruns:0 frame:0
          TX packets:325 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:24101 (23.5 Kb)  TX bytes:24101 (23.5 Kb)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:60.2.234.221  P-t-P:24.24.24.24  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:59169 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93069 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:3226834 (3.0 Mb)  TX bytes:129736692 (123.7 Mb)
[/code:1]
i re-wite it for u, druggo
[code:1]
stp=3
until [ $stp = 0 ]
do
ifconfig ppp0 | sed -n '2p;4p;5p;7p' >> log

p1=$(tail -10 log | sed -n '3p' | awk '{print $2}' | awk -F: '{print $2}')
p2=$(tail -9 log | sed -n '9p' | awk '{print $2}' | awk -F: '{print $2}')

p3=$((($p2 - $p1)/2))
echo $p3 "bytes per-second downloading" >> log


date >> log
echo '-------------------------------------------------------' >> log
tail -7 log
sleep 2
done


[/code:1]

let me if it works