|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Sybping...
Date: Aug 9 2000 6:30PM
tscheresky writes:
> Sybase provides a utility called sybping on Windows that tells me whether a
> particular Sybase Server is available. How would I emulate the same
> functionality using Perl and Sybperl, either through CTlib or DBlib?
Something like this:
#!/usr/local/bin/perl
use Sybase::CTlib;
$error = '';
sub handler {
$error .= join(' ', @_);
CS_SUCCEED;
}
ct_callback(CS_CLIENTMSG_CB, \&handler);
ct_callback(CS_SERVERMSG_CB, \&handler);
$dbh = new Sybase::CTlib 'sa', 'dabadoo!', $the_server;
if($dbh || $error =~ /4002|4067/) {
print "The server $the_server is up\n";
} else {
print "Can't reach $the_server: $error\n";
}
Examples:
1> perl ~/tmp/sybping.pl coconut
Can't reach coconut: 5 3 5 4 ct_connect(): network packet layer: internal net library error: Net-Lib protocol driver call to connect two endpoints failed Socket connect failed - errno 111
2> perl ~/tmp/sybping.pl xyz
Can't reach xyz: 5 3 4 3 ct_connect(): network packet layer: internal net library error: Specified server name attribute could not be found
3> perl ~/tmp/sybping.pl kiruna
The server kiruna is up
The 4067 error number above is what ASE 12.0 and later respond with if
the password is invalid.
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@peppler.org -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|