The way that you're calling system() bypasses the shell, so you're giving $CMD just 2 arguments (neither of which are valid switches for iptables) instead of the 12 you would be passing if you'd run that from the command line.
Instead, you want to force pre-parsing by the shell...
system("$CMD $arg1 $arg2");
...or emulate that behaviour yourself by making $arg1 and $arg2 arrays instead...
my $CMD = "/sbin/iptables"; my @arg1 = qw( -A INPUT -p tcp -m multiport --dport 80,8080 ); my @arg2 = qw( -s 10.10.10.10 -j DROP ); system($CMD, @arg1, @arg2) == 0 or die "can't fork: $!\n";
--k.
In reply to Re: problem with system function
by Kanji
in thread problem with system function
by perlknight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |