Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: problem with system function

by Kanji (Parson)
on Dec 05, 2002 at 19:44 UTC ( [id://217869]=note: print w/replies, xml ) Need Help??


in reply to problem with system function

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.


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://217869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-18 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found