function system()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Janusz

    function system()

    Hi!
    I'm trying do something like this, but it doesn't work.
    Please help.

    #!/usr/bin/perl
    $gw = 'ppp0';
    $ip = '192.168.1.2';
    # first way
    system("iptable s -t nat -A POSTROUTING -o $gw -s $ip -j MASQUERADE") || die
    "ERROR: $!"l;
    # second way
    system("iptable s", "-t", "nat", "-A", "POSTROUTIN G", "-o", $gw, "-s", $ip,
    "-j", "MASQUERADE ") || die "ERROR: $!"l;

    Janusz


  • Joe Smith

    #2
    Re: function system()

    Janusz wrote:
    [color=blue]
    > I'm trying do something like this, but it doesn't work.[/color]

    What do you mean, "doesn't work"?
    1) The 'iptables' command did not make the requested change, or
    2) The 'iptables' command did change the tables, but die() occurred.

    [color=blue]
    > system("iptable s -t nat -A POSTROUTING -o $gw -s $ip -j MASQUERADE") || die
    > "ERROR: $!"l;[/color]

    Re-read the docs. system() returns the error code; zero means no error.
    system("iptable s ...") && die "Failed: error code = $?\n";

    -Joe
    P.S. Don't post here, post to comp.lang.perl. misc instead.

    Comment

    Working...