ADSM-L

Access to ADSM Database via ODBC and Script?

2001-01-31 10:25:03
Subject: Access to ADSM Database via ODBC and Script?
From: Gerhard Rentschler <g.rentschler AT RUS.UNI-STUTTGART DOT DE>
Date: Wed, 31 Jan 2001 16:26:37 +0100
Hi,
I've just spent more than one day in vain trying to develop a script which
should get data from the ADSM DB via ODBC. First I used Active State Perl
(see http://www.activestate.com/Products/ActivePerl/ for more info) and
module Win32::ODBC. This crashes the whole perl interpreter. Using Jscript
with Windows Scripting Host and ADO leads to a serious runtime error.
However, according the activity log the connection to the server succeeds. I
will append both programs to the bottom of the mail.  The Jscript example is
incomplete. I get a log but this does not give any hint on the problem. I
was successful to use Excel 2000 to get the data from ADSM DB.

Has anyone managed to use a script to gather data from the *SM DB using
ODBC? Is there any information available on how to use the *SM ODBC driver
or on the error codes?

As stated in other mails access to ADSM management data is important. A
general administration API certainly would be much better. In the meantime a
ODBC driver which can be used from scripts would help me a lot. Getting the
data via calls to dsmadmc and redirection of command output is at least not
very elegant.

Best regards
Gerhard
---
Gerhard Rentschler            email:g.rentschler AT rus.uni-stuttgart DOT de
Gerhard Rentschler            email:g.rentschler AT rus.uni-stuttgart DOT de
Regional Computing Center     tel.   ++49/711/685 5806
University of Stuttgart       fax:   ++49/711/682357
Allmandring 30a
D 70550
Stuttgart
Germany

Here is the Perl script:


#! /usr/bin/perl
use WIN32::ODBC;
$db = new Win32::ODBC( "DSN=server;UID=bigadmin;PWD=secret" );
if (!($db)) {
 print "Error connecting zu rusadsm1 \n";
 print "Error: " . Win32::ODBC::Error(). "\n";
 exit;
}
$SqlStatement = "Select * from Nodes";
# the next statement causes the runtime error
if ($db->Sql($SqlStatement)) {
        print "Error connecting to rusadsm1 \n";
        print "Error:" . Win32::Error() . "\n";
        $db->Close();
        exit;
}
 while ($db->FetchRow()) {
        undef %Data;
        %Data = $db->DataHash();
        foreach $spalte (sort keys %Data) {
                print $spalte, '=', $Data{$spalte}, "\n";
        }
}
$db->Close();

And here comes the Jscript:

//example incomplete
var conn;
conn = new ActiveXObject("ADODB.Connection");
//the next statment causes the runtime error
conn.Open("server","bigadmin","secret");
var dbRecord = WScript.CreateObject("ADODB.Recordset");
var sql = "SELECT * FROM DB";
dbRecord.Open (sql, conn, adOpenKeyset, adLockOptimistic);
conn.Close();
<Prev in Thread] Current Thread [Next in Thread>
  • Access to ADSM Database via ODBC and Script?, Gerhard Rentschler <=