我在这里有一个小 bash 脚本,我正在尝试修复,但我不断收到一个语法错误,指出“文件意外结束”。它询问我是否要阻止或取消阻止并询问哪种类型的端口,然后出错。
任何帮助将不胜感激。
#!/bin/bash
PTYPET="What kind of port? [udp] or [tcp] or [both] :"
PTEXTT="What port? [number] :"
echo "Would you like to block or unblock? [b] or [u] :"
read choice
if [ $(choice) == "u" ]; then
echo $PTYPET
read port-type
echo $PTEXTT
read port
if [ $(ptype-text) == "both" ]; then
/sbin/iptables -A INPUT -p $port-type -m tcp --dport $port -j ACCEPT
/sbin/iptables -A INPUT -p $port-type -m udp --dport $port -j ACCEPT
else
/sbin/iptables -A INPUT -p $port-type -m $port-type --dport $port -j ACCEPT
fi
else
echo $PTYPET
read port-type
echo $PTEXTT
read port
if [ $(ptype-text) == "both" ]; then
/sbin/iptables -A INPUT -p $port-type -m tcp --dport $port -j DROP
/sbin/iptables -A INPUT -p $port-type -m udp --dport $port -j DROP
else
/sbin/iptables -A INPUT -p $port-type -m $port-type --dport $port -j DROP
fi