|
Hello:
I have a problem with this perl script because it's
not running well in linux.
It's only run if i login in linux
first.
Anybody can help me. Thanks, and sorry for my
english.
#!/usr/bin/perl
$DEFAULT = "170.210.254.1";
$BASE = 100; $IP = "/sbin/ip"; open RULE, "$IP rule show|";
while (<RULE>) {
next unless /^20:\s+from\s+(\d+.\d+.\d+.\d+)\s+lookup\s+(\d+)/; $borrar{$1} = $2; } close RULE;
open ROUTE, "$IP route show|";
while (<ROUTE>) {
next unless /dev ppp(\d+).+src (\d+.\d+.\d+.\d+)/; $route .= "nexthop dev ppp$1 "; if ($borrar{$2} == ($BASE+$1)) { delete $borrar{$2}; } else { $agregar{$2} = $BASE+$1; } } close ROUTE;
$route = "via $DEFAULT" unless $route;
$cambiar = 0;
foreach $ip (keys %borrar) {
# print "ip rule del from $ip table $borrar{$ip}\n"; system "$IP rule del from $ip table $borrar{$ip}"; $cambiar++; } foreach $ip (keys %agregar)
{
# print "ip rule add from $ip pref 20 table $agregar{$ip}\n"; system "$IP rule add from $ip pref 20 table $agregar{$ip}"; $n = $agregar{$ip} - $BASE; # print "ip route add default table $agregar{$ip} dev ppp$n\n"; system "$IP route add default table $agregar{$ip} dev ppp$n"; $cambiar++; } if ($cambiar) {
# print "ip route del default\n"; # print "ip route add default $route\n"; # print "ip route flush cache\n"; system "$IP route del default"; system "$IP route add default $route"; system "$IP route flush cache"; } |
- RE: This perl script not runing Marcelo A. Oliveto
- RE: This perl script not runing Dutrieux Yves
