home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # Copyright (c) 1995-1996 by Cayenne Software, Inc.
- #
- # This software is furnished under a license and may be used only in
- # accordance with the terms of such license and with the inclusion of
- # the above copyright notice. This software or any other copies thereof
- # may not be provided or otherwise made available to any other person.
- # No title to and ownership of the software is hereby transferred.
- #
- # The information in this software is subject to change without notice
- # and should not be construed as a commitment by Cayenne Software, Inc.
- #
- #---------------------------------------------------------------------------
- #
- # File : @(#)listdbs.tcl /main/titanic/1
- # Author : topr
- # Original date : October 1995
- # Description : List Informix Databases
- #
- #---------------------------------------------------------------------------
- #
-
- require subtdbop.tcl
-
- proc listDatabases {{dbHost ""}} {
-
- set listSect [TextSection new]
- set outFile [BasicFS::tmpFile]
- set errFile [BasicFS::tmpFile]
-
- $listSect append "DATABASE sysmaster;\n"
- $listSect append "OUTPUT TO $outFile WITHOUT HEADINGS\n"
- $listSect append "SELECT name FROM sysdatabases ORDER BY name;"
-
- set errMsg [executeCommandWithConnect $listSect $dbHost - $errFile 1]
-
- if {$errMsg != ""} {
- set errMsg "Unable to connect Informix sysmaster database\n$errMsg"
- set fileId [open $errFile r]
-
- while {![eof $fileId]} {
- set string [gets $fileId]
- if {$string != ""} {
- set errMsg "$errMsg\n$string"
- }
- }
-
- catch {close $fileId}
- catch {unlink $errFile}
- catch {unlink $outFile}
-
- error $errMsg
- }
-
- unlink $errFile
-
- set fileId [open $outFile r]
- set result ""
-
- while {![eof $fileId]} {
- set line [string trim [gets $fileId]]
-
- if {$line != ""} {
- lappend result $line
- }
- }
-
- close $fileId
-
- unlink $outFile
-
- return $result
- }
-