0
我有這樣的perl腳本perl的DBI->連接啪啪 「無路由到達主機」 雖然我可以選擇主機
wrapper.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use DBI;
# input params
my $end;
my $start;
my $url;
my @IP;
my $host = "localhost";
my $dbname = "flows";
my $username;
my $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 and send request to database
my $dbh = DBI->connect("DBI:Pg:dbname=".$dbname.";host=".$host, $username, $pass, {'RaiseError' => 1});
當我運行
./wrapper.pl -h 10.0.0.3
我得到:
DBI connect('dbname=flows;host=10.0.0.3','',...) failed: could not connect to server: No route to host
Is the server running on host "10.0.0.3" and accepting
TCP/IP connections on port 5432?
我可以ping服務器,也應該接受5432上的連接。 我可以收到此消息是因爲登錄憑據不正確嗎?
什麼'PSQL來自同一用戶帳戶-h 10.0.0.3 flows'和主機?同樣的結果? – 2013-03-27 02:39:55
冗餘使用串聯運算符:'「DBI:Pg:dbname = $ dbname; host = $ host」' - 插值您的標量變量。 – TLP 2013-03-27 02:45:25
'沒有路由到主機'聽起來像是操作系統本身的消息。 (我不知道是否有任何方法可以指定代理,但如果有,並且如果你這樣做,那麼主機可能是代理。) – ikegami 2013-03-27 03:32:14