Perl Gurus:
I trying to connect my perl script to a MS SQL Server from a Suse 11. I've tried using Freetds but was unsuccessful. I then tried downloading the Sybase AES ODBC libraries, but I'm not sure if just simply coping the Sybase.pm into the Perl library will work. Below is my script.
Your help will be appreciated.
#!/usr/bin/perl -w
use strict;
use warnings;
#You might need to define parameters for the input.
use DBI;
use Getopt::Long qw(:config no_ignore_case);
my ($status, $failed, $host, $verbose, $timeout);
my $VERSION = 0.1;
my $HELP = 0;
# Default values
$failed = 0;
my %STATUSCODE = ( 'OK' => '0',
'WARNING' => '1',
'CRITICAL' => '2',
'UNKNOWN' => '3');
my $usage = <<EOF;
Test
EOF
# handle cmdline args
my $result = GetOptions( "H|host=s" => \$host,
"h|help" => \$HELP,);
if( !$result ) {
print "ERROR: Problem with cmdline args\n";
print $usage;
exit($STATUSCODE{'UNKNOWN'});}
if( $HELP ) {
print $usage;
exit($STATUSCODE{'UNKNOWN'});}
if ( !($host) ){
print "ERROR: Missing required arguments\n";
print $usage;
exit($STATUSCODE{'UNKNOWN'});};
my $dsn = 'DBI:Sybase:server=prime';
my $dbh = DBI->connect('DBI:Sybase:server=test;UID=sa;PWD=;');
if (!$dbh){die "Could not open connection to DSN because of [$!]";}
my $query = $dbh->selectall_arrayref("SELECT COGIPF_STATUS
FROM [PVP21_Audit].[dbo].[COGIPF_AGENTRUN]
WHERE [COGIPF_LOCALTIMESTAMP] >= CONVERT(VarChar(20),
+GetDate() +1,101)", { Slice => {} }
);
foreach $query (@$query) {
if ($query->{COGIPF_STATUS} eq 'Failed') {$failed = 1}
}
unless (@$query) { $failed = 1 };
if ( $failed == 0 ) {
print "Jobs Succeeded\n";
exit($STATUSCODE{'OK'});
}elsif ( $failed == 1 ){
print "Job Failure\n";
exit($STATUSCODE{'CRITICAL'});
}else{
print "Undetermined error\n";
exit($STATUSCODE{'UNKNOWN'});
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|