Find out how many XPA access points are available that match a given name.
Integer_Type xpaaccess( String_Type dest ) Integer_Type xpaaccess( String_Type dest, String_Type accessmode )
This function returns 0, 1, or more to indicate how many instances of the given XPA application server(s) are currently running. The optional accessmode argument lists the type of access requested, which can be any combination of g, s, and i for get, set, and info access. See the XPA documentation for more information, in particluar the description of the xpaaccess command-line tool from the XPA distribution.
chips> require( "xpa" ) chips> xpaaccess( "prism" ) 1
The xpaaccess() call tells us that there is one XPA server running called "prism".
chips> !prism & chips> !prism -xpa bob & chips> xpaaccess( "prism" ) 1 chips> xpaaccess( "prism*" ) 2 chips> xpaaccess( "bob" ) 1
We start two new prism processes: the XPA access points for these will be called "prism2" (assuming the original prism is still running) and "bob". See "ahelp prism" and "ahelp session" for further information on how the access points are named. The xpaaccess() calls tell us there is one server that matches "prism" (this is the original prism), two that match "prism*" (the "*" acts as a wild card and so selects "prism" and "prism2" here), and one that matches "bob".
The following code shows how you can use this function in a S-Lang program (see "ahelp slsh" for more information on running S-Lang programs). When run with an argument the program will tell you how many servers whose name matches that of the argument.
#!/usr/bin/env slsh if ( 2 != __argc ) usage( __argv + " name" ); require("xpa"); variable nmatch = xpaaccess( __argv + "*" ); vmessage( "There are %d XPA servers that begin with '%s'", nmatch, __argv );
The Chandra X-Ray
Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA. Email: firstname.lastname@example.org
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.