thor_ping.pl

{
/* __________________________________________________________________________
                                         Copyright (C) DataAspects, Inc. 1998
  thor_ping.pl
  Objective: To determine if a database is currently loaded into Thor.
  Actions:
    1. Client pingthor.pl connects to server chemcop.pl 
       running on ThorServer & passes it two parameters:
         parm.0  db_exec -executes a SQL statement (see trim.h).
         parm.1  'pingthor', a flag instructing chemcop.pl 
                 to call the pingthor script.
         parm.2  name of the Thor database
    2. Execute chemcop.pl on the server.
    3. Chemcop.pl executes pingthor, a unix script.  
       pingthor takes two parameters as input, 
         parm.1 name of the database
         parm.2 name of the output ascii file 
    4. pingthor generates a list of all databases currently open 
       by Thor and available for searching and writes them to 
       the ASCII file.
    5.  Chemcop opens the ASCII file into a list and returns it to the client.
    6.  pingthor can be run from the command line:
        An example of a database currently loaded:
          etchem% pingthor 'cis'
          Opened "/usr1/daylight/thordb/cis.THOR@etchem:thor" with permission "r".

        An example of a database not loaded:
          etchem% pingthor 'acquire94'
          thordbping: Can't open database
             ERROR: can't find database "acquire94" (find_or_open_db)
...Pat McGreevy, 18 Feb 99
________________________________________________________________________________ */
char db[20];
char thorserver[20];
int  rc;
list db_list;
list temp_list;

db= prompt("Thor Db to ping: ");
db= lower(db);
if (db){
  db_list= list_open("20",1,"Thor DB List");
  list_mod(db_list,1,db);
  thorserver= "xxx.xxx.xx.xx";
  printf("Wait...Connecting to Chemcop on ThorServer");
  if (trap({
     connect(0,"net:chemcop@"^^G.thorserver^^"!vtxhost.trm");
     printf("  Connected to Chemcop");
     })){
         bell();
         printf("  Failed to connect to Chemcop");
         connect(0);
         break;
         }
  rc= (exec_sql("thor_ping",db_list));          /* TRIMrpc-remote procedure call */
  temp_list= list_open("select results",1000); /* TRIMrpc-remote procedure call */
  if (list_rows(temp_list))                            /* display error message */
    list_view3(temp_list,-2,-2,-1,key_f3,opt_highlight,0);
  }                                                           /* end if(db){... */
}