PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my settings
my profile
Public Pastes
Untitled
0 sec ago
Javascript Console...
5 sec ago
Problem:fetch prod...
1 sec ago
Watch Jersey Shore...
10 sec ago
java jsp type=&...
8 sec ago
Untitled
Java | 10 sec ago
How to set uniquen...
14 sec ago
Untitled
15 sec ago
charly
By: a guest on May 16th, 2008 | syntax:
Perl
| size: 0.96 KB | hits: 76 | expires: Never
download
|
raw
|
embed
|
report abuse
Copied
#!/usr/bin/perl -w
use
strict
;
use
warnings
;
use
DBI
;
exit
unless
(
grep
(
/mysql/
,
DBI
->
available_drivers
)
)
;
my
$db
=
"mysql"
;
my
$host
=
"localhost"
;
my
$port
=
"8889"
;
my
$dsn
=
"DBI:mysql:database=$db;host=$host;port=$port"
;
my
$username
=
"root"
;
my
$passwd
=
"root"
;
my
$dbh
=
DBI
->
connect
(
$dsn
,
$username
,
$passwd
)
or
die
"connexion impossible $DBI::errstr"
;
my
$sth
=
$dbh
->
prepare
(
"SELECT Host, User, Password FROM user;"
)
;
$sth
->
execute
(
)
or
die
"$DBI::errstr"
;
open
(
OUTFILE
,
">DBI.csv"
)
or
die
"ouverture en écriture impossible: $!"
;
while
(
my
(
$uhost
,
$user
,
$upasswd
)
=
$sth
->
fetchrow_array
(
)
)
{
print
OUTFILE
"$uhost,$user,$upasswd
\n
"
;
}
$sth
->
finish
(
)
;
$dbh
->
disconnect
(
)
;
close
OUTFILE
;
open
(
INFILE
,
"DBI.csv"
)
or
die
"ouverture en lecture impossible: $!"
;
while
(
<INFILE>
)
{
next
unless
(
$_
=~
/^.*,.*,.*$/
)
;
my
(
$uhost
,
$user
,
$upass
)
=
split
/,/
,
$_
;
print
"Host: $uhost, User: $user, Password: $upass
\n
"
;
}
close
INFILE
;
create a
new version
of this paste
RAW Paste Data