The file has the cr at the end of each line, but for reasons not clear
to me, each column is processed as a separate line in the loop, using
the diagnostic you suggested.
To make things clearer, here is the cat of the file
[root]# cat /etc/iptables/tcp.accept.dest.ports
#these are the tcp INPUT ports
#
22 ssh
25 smtp
80 http
111 portmapper
[more like these]
And here is the script output
[root]# ftest
22 ssh 25 smtp 80 http 111 portmapper 113 auth 735 ypserv 752 ypbind 3306 mysql 8021
zope FTP 8080 zope
line: 22
line: ssh
line: 25
line: smtp
line: 80
line: http
line: 111
line: portmapper
line: 113
[ more like these ]
The problem appears to be in the
lines=`cat $INFILE | grep -v "^[[:space:]]*#" | grep -v '^[[:space:]]*$'
2>/dev/null`
statement, which appears to eat the newlines, as this script suggests:
if [ -f $INFILE ]; then
lines=`cat $INFILE | grep -v "^[[:space:]]*#" | grep -v '^[[:space:]]*$'
2>/dev/null`
echo $lines
fi
Output (no new lines ??):
[root@nitace init.d]# ftest
22 ssh 25 smtp 80 http 111 portmapper 113 auth 735 ypserv 752 ypbind 3306 mysql 8021
zope FTP 8080 zope
JDH