Well, apparently my suspicion was not correct. The following script fails with a "segmentation fault" on the second user. The first user's id and password are not correct, so connect fails and the script behaves as expected - it continues with the next userid/password. The 2nd password is correct, so the connect should be successful. In this case, a message should be recorded in the log file, the current user disconnected, script paused and restart with the next userid/password set. But the connect fails and nothing is recorded. Is there something obvious in the script that I am missing? Thanks in advance,
-Mahtaj ---------------- #!/usr/local/bin/perl -w use DBI; use Env qw(PATH ORACLE_HOME ORACLE_SID); use strict; use strict 'vars'; $PATH = ""; $ORACLE_HOME = "/u01/app/oracle/product/806"; 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 (0); 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"; $dbh->disconnect; sleep 5; } } close LOG; close INPUT; Here's the output: logging into DBNAME as USER1/PASS1 #this password is incorrect logging into DBNAME as USER2/PASS2 #this password is correct Segmentation Fault > -----Original Message----- > From: Khamneian, Mahtaj > Sent: Thursday, February 07, 2002 11:34 AM > To: Jared Still; [EMAIL PROTECTED] > Subject: RE: Perl DBI->connect > > > You're right. I have been working with shell scripts, using > sqlplus, too long. > What I need to do is to continue (rather than die) the > script, attempting to connect with another userid/passwd, > when a connection fails and I get "Segmentation Fault" after > the first successful login. Now, I have a suspicion that > there is a time conflict between disconnect and the next > connect. Maybe I should make the script wait a little after > each disconnect. Any suggestions/comments? > > Thanks a lot for the pointer, > > -Mahtaj > > > -----Original Message----- > > From: Jared Still [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 07, 2002 11:07 AM > > To: Khamneian, Mahtaj; [EMAIL PROTECTED] > > Subject: Re: Perl DBI->connect > > > > > > > > Are you sure you're using DBI? > > > > If the password is incorrect, the connection should fail. > > > > The behavior you describe is typical of Sqlplus. > > > > Assuming that you have a scott/tiger account, the following script > > should simply fail and report an error: ( change the value of > > $db first ) > > > > #!/usr/bin/perl > > > > use warnings; > > use DBI; > > use strict; > > > > my ($db, $username, $password) = qw{ts01 scott notiger}; > > > > my $dbh = DBI->connect( > > 'dbi:Oracle:' . $db, > > $username, $password, > > { RaiseError => 1, AutoCommit => 0, ora_session_mode => 0 } > > ); > > > > die "Connect to $db failed \n" unless $dbh; > > my $MySql="select \* from dual"; > > my $sth = $dbh->prepare($MySql); > > $sth->execute; > > > > my $href = $sth->fetchrow_hashref; > > print "DUMMY: $href->{DUMMY}\n"; > > > > $sth->finish; > > $dbh->disconnect; > > > > Jared > > > > > > > > On Thursday 07 February 2002 08:06, Khamneian, Mahtaj wrote: > > > I have written a perl DBI script to check passwords of some > > 1500 users on > > > an oracle database. I have set up a loop to go through a > > list containing > > > userid:password of each user on a separate line. I use > > DBI->connect to > > > connect to the instance using the userid/password from > the list. If > > > connection is successful, I record the info in a file and > > disconnect from > > > the db and check the next userid/passwd with another > > connect. The problem > > > is when the wrong password is supplied, oracle prompts for > > correct userid. > > > What oracle state is this(I cannot disconnect because I'm > > not connected)? > > > And how can I handle it in perl? Is there a more efficient > > way to do this > > > in perl than what I have explained above? > > > > > > Thanks, > > > > > > ------------------------------------- > > > Mahtaj Khamneian > > > University of Missouri - ASP Phone : (573) 884-2281 > > > 1805 East Walnut Fax : (573) 884-3070 > > > Columbia, MO 65201-6425 [EMAIL PROTECTED] > > >