Bryan, this question has nothing to do with DBI, but since I
see that the script being run(checkdns.pl) does use DBI, I guess
it's not completely off-topic.
You actually want to have update.pl "execute" checkdns.pl right?
There are a few options to consider, but dot slashing it is not
one of them.
* if you just want to execute the script and NOT collect any
output from it, you can use the perl "system" function
* read about "system" by doing "perldoc -f system" at
a command prompt
* if you want to execute the script *AND* collect any output
generated by that script, then you want to use backticks -
I'm not sure how to find the "backticks" discussion in the
perldocs, but I'm pretty sure it's there - you just have
to find it. Also, any of the perl books should describe it.
You can also use a version of pipe open to gather output from
a script you're executing, but one of the above may be sufficient
for you.
HTH.
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com
Bryan Tolka [[EMAIL PROTECTED]] wrote:
> 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;
>
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com