When i run the curl statement from the command line, it runs just fine and does what i expect it to do.
But when i run it from the perl script, it produces the error above. That is why i am confused.
Let me clarify one thing, the mysql.sh script is actually the
mysql.pl script. I just manually edited the extension when posting this here. I also just edited the mysql.sh script by using bash, when the original code that was producing this error is actually perl code. So here is the original perl code in
mysql.pl that was producing this error. Sorry for creating this confusion.
#!/usr/bin/perl
use 5.010;
use strict;
use DBI;
use IO::File;
INIT {
my $now = localtime();
print "$now\n";
my $fh = IO::File->new('/net/account/admin/george/BK/account.txt') or croak $!;
my $username = $fh->getline;
my $password = $fh->getline;
$fh->close;
chomp $password;
chomp $username;
my $rmt = '10.1.4.101';
my $dbrmt = DBI->connect("dbi:mysql:database=;host=$rmt", $username, $password, {mysql_connect_timeout => 1});
# CHeck if remote mysql server status
if (!defined $dbrmt) {
print "Cannot connect to mysql on db-gc-pxc1.\n";
exit -1;
}
if ( $dbrmt->do("SELECT 1") ) {
print "Mysql on db-gc-pxc1 is running.\n";
}
else {
print "Select 1 Error.";
exit -1;
# execute "SELECT 1" error, return exit -1 for instance
}
$dbrmt->disconnect;
}
__END__
So basically, what i want to do is that if the remote mysqld is down, i want to change the tag on the local consul service (originally set to inactive) to "active" status.
So this perl script is actually checking the status of a mysqld on a remote server. When i run the perl script from the command line without the curl line, it runs just fine. But when i add the curl statement, thats when i am getting the reported error.