i have perl script
wrapper.pl
#!/usr/bin/env perl use strict; use warnings; use getopt::long; use dbi; # input params $end; $start; $url; @ip; $host = "localhost"; $dbname = "flows"; $username; $pass; getoptions ("s|start=s" => \$start, "e|end=s" => \$end, "r|url=s" => \$url, "ip|iplist=s" => \@ip, "h|host=s" => \$host, "db|dbname=s" => \$dbname, "u|username=s" => \$username, "p|pass=s" => \$pass); # connect , send request database $dbh = dbi->connect("dbi:pg:dbname=".$dbname.";host=".$host, $username, $pass, {'raiseerror' => 1});
when run
./wrapper.pl -h 10.0.0.3
i :
dbi connect('dbname=flows;host=10.0.0.3','',...) failed: not connect server: no route host server running on host "10.0.0.3" , accepting tcp/ip connections on port 5432?
i can ping server , should accept connections on 5432. may message because of bad login credentials?
first should use dbd::pg;
after use dbi;
secondly add dbi->errstr
more proper error
my $dbh = dbi->connect("dbi:pg:dbname=".$dbname.";host=".$host, $username, $pass, {'raiseerror' => 1}) or die dbi->errstr;
third should able connect psql commandline before triyng dbi
psql -h 10.0.0.3 -u username -d dbname -p 5432
(please check syntax)
Comments
Post a Comment