I can't find anything on the web about this but I can find that I shouldn't use quotes on the EOT but in my case I don't so if anyone could help me here that would be awesome..........
This is part of a script to setup new Debian installs
PROBLEM:
I don't get access to $PORT inside the cat/EOT here-document when it runs.
setUPiptables()
{
    if ! grep -e '-A INPUT -p tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules
    then
        cat << EOT >> /etc/iptables.test.rules
        *filter
        IPTABLES-CODE-HERE
        # Allows SSH connections
        # The --dport number is the same as in /etc/ssh/sshd_config
        -A INPUT -p tcp -m state --state NEW --dport $PORT -j ACCEPT
        IPTABLES-CODE-HERE
        COMMIT
EOT
        sleep 5
        /sbin/iptables-restore < /etc/iptables.test.rules || exit 127
        sleep 5
        /sbin/iptables-save > /etc/iptables.up.rules || exit 127
        sleep 3
        printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables
        chmod +x /etc/network/if-pre-up.d/iptables
        sleep 6
    fi
}
QUESTION:
Can you find/see the problem with $PORT in the cat iptables code?
 
     
    