What do you mean with "it's only run if I login in linux first" ?
Do you mean you execute the script in background with a cron ?
Do you have the same environment variable when the script is in background ?
What kind of error do you have ?
Yves
-----Message d'origine-----
De: Marcelo A. Oliveto [mailto:[EMAIL PROTECTED]]
Date: mardi 11 d�cembre 2001 17:05
�: [EMAIL PROTECTED]
Objet: This perl script not runing
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";
}
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin