>Hi!
>
>Is there any way (environment variable, Ingres command etc...) to check from
>inside an application if it is running on a client machine (ie. only
>the Ingres name server and NET are running) or on a server machine?
>
>I need to know this because certain administrative operations are not allowed
>from a client machine.
>
>Thank You
>--
>Tommi.Joutsiniemi@prodax.fi
Yes. Well, kinda. I do this by looking at the Ingres environment
variable II_RUN. This can be accessed with the command
ingres% ingprenv1 II_RUN
On a server, it is usually defined as
II_RUN=,DBMS,NET
while on a client is is
II_RUN=,NET
Here is a C function you might find handy for reading Ingres
environment variables within an application:
-------------------------------------------------------------------------------
#define DB_INGPRENV1_STRING "$II_SYSTEM/ingres/bin/ingprenv1 "
long db_getenv
(
char *env_var, /* The environment value to translate */
char *buf, /* The buffer to translate into */
int buf_size /* The size of the buffer */
)
{
FILE *pfp; /* Pipe file descriptor */
char *str; /* utility string pointer */
long ret_val=DB_FAIL; /* Return status, assume failure */
/*
| Malloc a string big enough to
| construct the ingprenv1 command.
*/
str=malloc(sizeof(DB_INGPRENV1_STRING)+strlen(env_var)+1);
if (str!=NULL) {
/*
| Determine the value of the II_CONFIG symbol,
| by piping in the output of the ingprenv1 command.
*/
sprintf(str, "%s%s", DB_INGPRENV1_STRING, env_var);
pfp=popen(str, "r");
free(str);
if (pfp!=NULL) {
/*
| Get the data returned from the ingprenv1 command.
*/
str=fgets(buf,buf_size-1,pfp);
if(str!=NULL) {
/*
| Remove the newline, if necessary.
*/
str=strchr(buf, '\n');
if (str!=NULL)
*str='\0';
/*
| Close the command pipe and check the
| commands exit status.
*/
if (pclose(pfp)==0)
ret_val=DB_OKAY;
else
ret_val=DB_FAIL;
} /* fgets ok */
} /* popen ok */
} /* malloc ok */
/*
| Return the status.
*/
return(ret_val);
} /* db_getenv() */
-------------------------------------------------------------------------------
As usual, all disclaimers apply.
|--------------------------------------------------------------------------|
| Michael Leo | The Ingres FAQ is at ftp.adc.com, /pub/ingres. |
| York & Associates, Inc.| Also check out /pub/ingres/utilities/NAIUA for |
| Minneapolis, MN, USA | the NAIUA Tool Kit. Lastly, access all this via|
| (612) 921-8083 (voice) | WWW at http://www.adc.com/ingres/ing-top.html. |
| mal@winternet.com | All constructive suggestions/criticism welcome. |
|--------------------------------------------------------------------------|
Ingres Q & A
To William's Home Page
© William Yuan 2000
Email William