Make this line:

   my @login=split(/:/,$line);

be this:

   my @login=split(/:/,chomp($line));

You are getting hit with the end-of-line character.


On Fri, 8 Feb 2002, Khamneian, Mahtaj wrote:

> 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;
>

-- 
--------------------------------------------------------------------------
Cliff Nadler            Collective Technologies, Inc.
[EMAIL PROTECTED]    (512)-263-5500
--------------------------------------------------------------------------
To win, you must treat a pressure situation as an opportunity to succeed,
not an opportunity to fail                      Gardner Dickinson

Reply via email to