ADSM-L

Re: Access to ADSM Database via ODBC and Script?

2001-02-01 02:02:49
Subject: Re: Access to ADSM Database via ODBC and Script?
From: Xavier Merlin <xavier.merlin AT KBC DOT BE>
Date: Thu, 1 Feb 2001 08:02:22 +0100
Very interesting and quite a coincidence !

Yesterday I was reading perl and when I read something about ODBC I said to
myself: this is the thing to use  if it works with adsm.

Right now I am using a construct like system(" dmsadmc -id=secret  -pa=secret <
some_sqlscript") from within a perl script , the some_sqlscript does contains
select ... from ... where ... clauses.

It would indeed be nicer to query directly the tables from within perl using
ODBC for that.

I am quite novice on ODBC and these things intrigue me, so let me know if there
is anything to learn from you adsm guru guys on this subject

Xavier




        g.rentschler AT RUS.UNI-STUTTGART DOT DE
        31/01/01 17:01

                 To: ADSM-L AT VM.MARIST DOT EDU@Internet
                 cc: (bcc: Xavier Merlin/U18218/KB/KredAlm)
                 Subject: Access to ADSM Database via ODBC and Script?

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>