fi


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fi
# 1  
Old 07-27-2008
fi

Does anybody know what is wrong here. I am running centOS
Code:
the anticrash gives me this.

#!/bin/sh

while true
do
  rm banme.tmp
  :> banme.txt
  /usr/sbin/tcpdump -p -c 100 -n -i eth0 "dst host 66.197.12 6.19 and udp port 7777" >banme.tmp 
  grep "length 0" banme.tmp | cut -f 3 -d " " | cut -f 1-4 -d "." >> banme.txt
  if [ `grep -c . banme.txt` -gt 0 ]
  then
    ip=`head -1 banme.txt`
    if [ `grep -c ${ip} /etc/sysconfig/iptables` -eq 0 ]
    then
      dat=`date`
      echo "${dat} adding ${ip} to iptables" >> banme.log
      /sbin/iptables -A INPUT -s ${ip} -j DROP      
      /sbin/iptables-save > /etc/sysconfig/iptables
    else
      echo "${ip} is already in iptables" 
    fi   //LINE 20<<
  fi
  sleep 0
done

[root@inerdtech control]# sh ./anticrash.sh
: command not founde 2:
./anticrash.sh: line 20: syntax error near unexpected token `fi'
'/anticrash.sh: line 20: ` fi
# 2  
Old 07-27-2008
Comment the red part of of your fi command :
Code:
    else
      echo "${ip} is already in iptables" 
    fi   # //LINE 20<<

Jean-Pierre.
# 3  
Old 07-27-2008
Quote:
Originally Posted by aigles
Comment the red part of of your fi command :
Code:
    else
      echo "${ip} is already in iptables" 
    fi   # //LINE 20<<

Jean-Pierre.
the comment doesnt exist in the real script it was simply used to show what line it was any ideas
# 4  
Old 07-27-2008
The script seems to be proper, check the file with vi, do you see a ^M at the end of a lines?
# 5  
Old 07-27-2008
// is not comment marker

Hi
I used # in line 20, thus:
Code:
    fi   # //LINE 20<<

That works!
Graham
# 6  
Old 07-27-2008
[root@inerdtech control]# sh ./anticrash.sh
: command not founde 2:
./anticrash.sh: line 20: syntax error near unexpected token `fi'
'/anticrash.sh: line 20: ` fi #//LINE20

these are what i get if i use the #//line20 and also no i donot have ^M any other suggestions?
# 7  
Old 07-27-2008
  1. Try to execute your script with the command :
    Code:
    /bin/sh ./anticrash.sh

  2. Execute your script with the debug option, and show us the output:
    Code:
    which sh
    sh -vx ./anticrash.sh


Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question