Hello everyone. I have a script below that opens another file
checkdns.pl and executes a while loop. I would like to pass it a
variable $dnsName. This however seems to be eluding me and my poor
scripting abilities. The checkdns.pl script works when executing the
file itself. Is this the correct syntax for passing a variable?
Thanks any help is appreciated.
####### update.pl file #########
if ( ($oldip eq $ip) && ($os ne "router") && ($os ne "hub") &&
($bootType ne "conduit") ){
open (DNSQeury,"./checkdns.pl $dnsName");
while (<DNSQeury>){
if ( (/(\d+\.\d+\.\d+\.\d+)/) && ($dnstest ne $ip) && ($bootType ne
"reserved") ){
print "<strong>DNS name $dnsName, already assigned to $dnstest, added
nothing</strong>";
exit;
}
print " DNStest is $dsntest";
}
}
### checkdns.pl file #######
#!/usr/bin/perl
print"Content-type: text/html\n\n";
use DBI;
$dbh = DBI->connect("DBI:mysql:netmgt:localhost","root","spider");
#print "enter dnsname ... " ;
$dnstest=<STDIN>; ## input
#chomp ($dnstest);
$sth=$dbh->prepare("select ip from ipmgt where (dnsName = '$dnstest')");
$sth->execute;
$rv= $sth->rows;
print "Number of records found:$rv\n"; ## Testing purposes
$sth->finish;
$dbh->disconnect;
exit;