line break format in the text file?  it seems like the for-in should
initialize $line, but we're assuming it's grabbing the lines correctly.
Is the file format data[space]data[space] for one line or is it
data[space]data[cr]?

maybe try this to take a looksee:

#!/bin/sh

export INFILE=/etc/iptables/tcp.accept.dest.ports
if [ -f $INFILE ]; then
    #get the lines, ignoring empties and comments
    lines=`cat $INFILE | grep -v "^[[:space:]]*#" | grep -v '^[[:space:]]*$' 
2>/dev/null`
    for line in $lines; do
        echo $line
        echo
    done
else
    echo "Can't find $INFILE"
fi

exit

Also, on further inspection, it looks as if you've left out the exit
statement.  Perhaps the app works just fine, and what you see at the end
is just the shell you entered to run the script.

tack

> #some comments
> 22  ssh
> 25  smpt
> 80  http

> .............

> #!/bin/sh
>
> export INFILE=/etc/iptables/tcp.accept.dest.ports
> if [ -f $INFILE ]; then
>     #get the lines, ignoring empties and comments
>     lines=`cat $INFILE | grep -v "^[[:space:]]*#" | grep -v '^[[:space:]]*$' 
>2>/dev/null`
>     for line in $lines; do
>         col1=`echo $line | awk '{print $1}'`
>         col2=`echo $line | awk '{print $2}'`
>         echo "column 1 is $col1 and column 2 is $col2"
>     done
> else
>     echo "Can't find $INFILE"
> fi

Reply via email to