【发布时间】:2019-02-16 12:15:00
【问题描述】:
我在网上找不到任何关于此的信息,但我发现我不应该在 EOT 上使用引号,但就我而言,如果有人可以在这里帮助我,那将是很棒的。 .........
这是设置新的Debian 安装脚本的一部分
问题:
cat/EOT here-document 运行时,我无法访问 $PORT。
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
}
问题:
您能在cat iptables 代码中找到/看到$PORT 的问题吗?
【问题讨论】: