dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with bash?

  1. #1
    Join Date
    Jan 2010
    Location
    Perth
    Posts
    133

    Help with bash?

    Hello

    I cant get the script below to work.

    I only want it to show the IP's and DNS name of the IP.

    Example

    HTML Code:
    STORE=$1
    
    #get stores ip bit
    IPBIT=`nslookup s$STORE.internal.XXXXXXX.com.au | tail -2 | head -1 | cut -d" " -f 2 | cut -d"." -f1,2,3`
    IPBIT2=`echo $IPBIT | cut -d"." -f1,2`
    IPBIT3=$((`echo $IPBIT | cut -d"." -f3`))
    REGIP=$IPBIT2.$IPBIT3
    
    X=0
    IPLIST=" "
    while [ $X -lt 255 ]
    do
            IPLIST="$REGIP.$X $IPLIST"
            X=$(($X+1))
    done
    EXP=$STORE."l"
    for y in $IPLIST; do
    
            dns=`nslookup $y | tail -2 | head -1 | cut -d"=" -f2`
            if echo $dns | grep "can't" >/dev/null 2>&1
            then
                    fdg=0
            else
                    if [[ $dns =~ $EXP ]]
                    then
                            echo "---";
                    echo $y $dns
                    fi
            fi
    done

  2. #2
    Join Date
    Oct 2007
    Location
    Vienna, Austria
    Posts
    393
    It would be surely interesting to trace your script and look for errors in it... surely it would make for an interesting hour, which I need to spend working. So, in order to help you, I need your help:
    1. Give an example input and desired output
    2. Comment each block saying what it's supposed to do and whether it works

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles