petar.company/tools/system2petar/.old/radius-convert-old-fmt.pl
2025-03-01 00:58:18 +01:00

25 lines
675 B
Perl
Executable file

#!/usr/bin/perl
if (@ARGV[1] eq ""){
print "Usage: ";\
print "$0 old_format_db_file vendor_name\n";
exit 5 ;
}
print "\n";
print "Ready to generate sql file for : @ARGV[0] \n";
print "This hosts belong to vendor : @ARGV[1] \n";
print "\n";
print "Press any key to continue or Ctrl+C to abort";
$key = getc(STDIN);
print "\n";
open (IN, "<@ARGV[0]") or die "Error opening @ARGV[0]" ;
open (OUT, ">import.sql");
while ($line = <IN>){
chomp $line;
($ip,$netmask,$pwd,$login,$opt1) = split ("\t",$line);
print OUT "INSERT INTO RADIUSUSER (ip,netmask,login,pwd,vendor,opt1,opt2) VALUES (\'$ip\',\'$netmask\',\'$login\',\'$pwd\',\'@ARGV[1]\',\'$opt1\',\'$opt2\');\n";
}