我想在etter.conf文件中取消註釋行168。該命令在終端中運行OK,但在perl中嘗試時出現錯誤。使用sed替換perl中的行
system ("sed -i '168s/.*/redir_command_on = "iptables -t nat -A PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport"/' /etc/etter.conf");
錯誤是:
Bareword found where operator expected at ./attack.pl line 135, near
""sed -i '168s'/.*'/redir_command_on = "iptables"
我覺得是有一些做的特殊字符和轉義。
您需要轉義嵌套引號。 Perl認爲iptables應該是可變的。 –
命令中的雙引號正在終止perl字符串。 – Barmar
你是否有理由對'sed'進行炮擊? Perl完全可以自行更新文件。 – Barmar