(RADIATOR) Question on flat ISDN-users file -> CDB.

Jon Nistor nistor at primus.ca
Thu Jun 7 10:51:34 CDT 2001


Hi there, I'm new to the list =)  just to start that off.  I've checked
the archives as well, and didn't find anything, so hopefully this won't be
redundant, if so, sorry :/

I'm trying to convert out ISDN users file, which is automatically
generated from values in oracle that are pulled down into a flat file that
looks like this:

#----------------------------------------------------------------
# NOTE: This file is autogenerated from a database.
# Any manual changes will be lost when the database is updated
# and this file is refreshed!!!
#----------------------------------------------------------------

# 1197538
aaacredit:      Encrypted-Password = "HSaooI.RbBbxU" #
        Service-Type = Framed,
        Framed-Protocol = PPP,
        Framed-IP-Address = x.x.x.x,
        Framed-Route = "x.x.x.x/30 x.x.x.x 1",
        Framed-IP-Netmask = 255.255.255.255,
        Port-Limit = 2,
        Idle-Timeout = 1234342

# 1197843
abmtools:       Encrypted-Password = "Dt4DbQJyZ7PUI" #
        Service-Type = Framed,
        Framed-Protocol = PPP,
        Framed-IP-Address = x.x.x.x,
        Framed-Route = "x.x.x.x/29 x.x.x.x 1",
        Framed-IP-Netmask = 255.255.255.255,
        Port-Limit = 2,
        Idle-Timeout = 120


---------------

And I'd like to covert it to something like:

+9,252:aaacredit->Encrypted-Password = "HSaooI.RbBbxU"
        Service-Type = Framed,
        Framed-Protocol = PPP,
        Framed-IP-Address = x.x.x.x,
        Framed-Route = "x.x.x.x/30 x.x.x.x 1",
        Framed-IP-Netmask = 255.255.255.255,
        Port-Limit = 2,
        Idle-Timeout = 1234342
+8,251:abmtools->Encrypted-Password = "Dt4DbQJyZ7PUI"
        Service-Type = Framed,
        Framed-Protocol = PPP,
        Framed-IP-Address = x.x.x.x,
        Framed-Route = "x.x.x.x/29 x.x.x.x 1",
        Framed-IP-Netmask = 255.255.255.255,
        Port-Limit = 2,
        Idle-Timeout = 120

........

I have a perl script that looks like this:
#!/opt/perl5/bin/perl

$tmpusers = @ARGV[0];

if (! @ARGV) {
        print "Might wanna specify a filename\n";
}

open(FILE,"$tmpusers") || die "Couldn't open $tmpusers\n";;
while (<FILE>) {
        if (/^(.+):\s+.+Password = \"(.+)\"/) {
                $block = "+" . length($1) . ",GHETTO_LENGTH:$1->Encrypted-Password = \"$2\"\n";
        } elsif (/^$/) {
                if ($block =~ /->(.*)$/s) {
                        $length = length($1);
                        $block =~ s/GHETTO_LENGTH/$length/;
                        print $block;
                }
        } elsif (!/^#/){
                $block .= $_;
        }
}
print "\n";
close(FILE);

.......

now here's the question:

I wanna use CDB_File to make the file directly, but I can't get
$cdb->insert to work properly on the value's.  (not a perl guy =/).  Does
anyone have an idea of an easier way to conver it or any place with goodie
scripts? :)

Thanks,

-- 
.+.+.=.....+.....*..-...\//...-..+..._+($)(_)# ......%%@......[]@#.....!
Jon (nistor at primus.ca)     Unix Systems Administrator, Primus Canada.
Tel.  (416) 207-7612


===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list