Erro na função for

Iniciado por Paulinunes, 17 de Novembro de 2011, 13:35

tópico anterior - próximo tópico

Paulinunes

Eu estava instalando alguns módulos do webmin e encontrei um que me dá as estatísticas em tempo real do squid.

O problema é que ao tentar acessar esse modulo ele me dá o erro:
/usr/share/webmin/sq-real-mon-1.0/real.cgi: 31: Syntax error: Bad for loop variable

O que pode ser?

Tá aí o script:

#!/bin/sh

#########################################
# Author : Aniruddha Karanjkar          #
# Script name :real.cgi                 #
# Created on :13-May-2011               #
# Description:                          #
# Squid real time access monitor.       #
# Simple shell-script for monitoring    #
# squid internet access.                #
# email : aniruddhk@gmail.com           #
#########################################

echo -e "Content-type: text/html\n\n"


echo "<html>"
echo "<head>"
echo "<meta http-equiv=\"refresh\" content=\"5;url=\"\">"
echo "<link rel='stylesheet' type='text/css' href='/unauthenticated/style.css' />"
echo "</head>"
date
echo "<br />"

cur_time=`date +%s`
span=10 #Seconds back


cat /dev/null > part.log
back_time=`expr $cur_time - $span`
for ((t=0;t<=$span;t++));do
   s=`expr $back_time + $t`
   egrep $s /var/log/squid/access.log | awk '{print $8","$3","$7}'>> part.log
done

sort part.log |uniq >filtered.log

for u in `cat filtered.log|cut -d, -f1|uniq`;do
   echo "<font color=#775577 ><b>$u</b></font> <br>"
   for ip in `egrep -e "$u," filtered.log|cut -d, -f2|sort|uniq`;do
      echo "&nbsp;&nbsp;|-<font color=#557777 ><b>$ip</b></font><br>"
      cat /dev/null > sites
      for s in `egrep -e "$u,$ip," filtered.log|cut -d, -f3|sort|uniq`;do
         webdom=`echo $s|cut -d"/" -f3`
         echo "&nbsp;&nbsp;|&nbsp;&nbsp;|-<font color=#228822 >$webdom</font><br>">>sites
      done
      cat sites|sort|uniq
      echo "&nbsp;&nbsp;|&nbsp;&nbsp;<br>"
   done
   echo "<br>"
done