我正在尝试比较使用spacewalk注册的服务器列表和数据库中的服务器列表。以下不打印服务器存在于数据库中。服务器确实存在于数据库中,但它并没有将其打印出来。你可以检查一下,告诉我哪里可能犯了错误吗?
my @swsrvlist = qx(/bin/spacecmd -q system_list 2>/dev/null);
foreach(@swsrvlist)
{$select1 = "select host from hosts where host = '$_';";
print "running SQL --- " . $select1. " --- against mysql.\n" if $debug;
my $records1 = $dbh->prepare($select1);
$records1->execute;
while (my @data1 = $records1->fetchrow_array) {
print "$data1[0]";
$records1->finish;
}
}
当我打开脚本中的调试时,我得到了以下结果。
running SQL --- select host from hosts where (host = 'swprxy01.xxxx.com
'); --- against mysql.
running SQL --- select host from hosts where (host = 'bldtest10.xxxx.com
'); --- against mysql.