Mahtaj,

Try
        chomp($line);

before the split.

Jeff

> 
> After some debugging using DBI->trace, I found out the value of 
> the password is not passed correctly to DBI->connect (hard coding 
> the password directly in connect worked). Apparently "split" is 
> attaching something (eoln?) to the password value which makes it 
> invalid when passed to oracle via connect.
> The input file contains lines of the form:
> USERID:U123456
> ..
> ..
> ..
> 
> My attempts to parse the input lines correctly have failed so far.
> Any suggestions?
> 
> Thanks again.
> 
> -Mahtaj
> 
> Here's the script:
> 
> ----------------
> #!/usr/local/bin/perl -w
> 
> use DBI;
> use strict;
> use strict 'vars';
> 
> my ($user, $password, $sid);
> my $line;
> $sid = "DBNAME";
> 
> my $filename = "login_list";
> 
> # open log file for recording
> open LOG, '>/tmp/bd_passwd_list';
> 
> open(INPUT, "<$filename")
>    or die "can't open $filename \n";
> 
> DBI->trace (2);
> 
> while($line = <INPUT>)
> {
>    my @login=split(/:/,$line);
> 
>    $user = $login[0];
>    $password = $login[1];
> 
>    # connect to target db
>    print " logging into $sid as $user/$password\n";
>    my $dbh = DBI->connect ("dbi:Oracle:$sid", $user, $password, { 
> PrintError => 0, RaiseError => 0 });
> 
>    if ($dbh)
>    {
>       print LOG "$user is using birthday $password as password\n";
>    }
> 
> }
> close LOG;
> close INPUT;
> 
> exit 0;
> 

Reply via email to