Results 1 to 4 of 4

Thread: Shell Acript Help

  1. #1
    Join Date
    Mar 2008
    Location
    Back to India
    Beans
    278
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    Red face Shell Acript Help

    Hi,
    I have created the below shell script:

    #!/bin/bash
    TotalData=$(grep dove /var/log/auth.log | grep "authentication failure" | awk '// {print $13 "," $14}' | replace "ruser=" "" | replace "rhost=" "")
    $(iptables -F input-pop-hack-blocked)
    for i in $TotalData
    do
    UserName=$(echo $i | cut -d"," -f 1)
    UserIp=$(echo $i | cut -d"," -f 2)
    echo "UserName = $UserName , UserIp = $UserIp "
    if [ -d "/home/$UserName" ]; then
    {
    (echo "User $UserName Exist")
    }
    else
    {
    (echo "User $UserName does not Exist")
    if [$(iptables -L input-pop-hack-blocked -vn | grep $UserIp)]; then
    {
    (echo "iptables -A input-pop-hack-blocked -i eth1 -s $UserIp -p tcp --dport 110 -j DROP")
    $(iptables -A input-pop-hack-blocked -i eth1 -s $UserIp -p tcp --dport 110 -j LOG --log-level 4 --log-prefix " FW POP $UserIP DROP")
    $(iptables -A input-pop-hack-blocked -i eth1 -s $UserIp -p tcp --dport 110 -j DROP)
    $(echo "iptables -A input-pop-hack-blocked -i eth1 -s $UserIp -p tcp --dport 110 -j DROP") >> /var/log/HackPopAuthMessage
    }
    else
    {
    (echo " IP Address $UserIp for Username $UserName aleeady added to firewall ")
    }
    fi
    }
    fi
    done
    I am getting the following error.

    ./HackPopAuth: line 17: []: command not found
    Seeking help to resolve this problem.
    Any help welcome.

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,438
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Shell Acript Help

    what's up with all these {} ()? and captured commands doing nothing? o.O
    this code doesn't look like your average shell script at all



    _ = space here
    Code:
    if [_<stuff>_]
    error is located here:
    Code:
    if [$(iptables -L input-pop-hack-blocked -vn | grep $UserIp)]; then
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Mar 2008
    Location
    Back to India
    Beans
    278
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    Unhappy Re: Shell Acript Help

    Thanks for the reply.

    i am sorry; I did not get your point. I can understand this is some very basic error; but I am facing this for long and did not get the logic for the same.

    It will be a great help if you can hemp me in a bit detailed manner.

    Thanks again.

  4. #4
    Join Date
    Mar 2008
    Location
    Back to India
    Beans
    278
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    Talking Re: Shell Acript Help

    Hi Thanks for your reply again. I got the solution here
    http://www.linuxcommand.org/wss0100.php


    thanks again

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •