Consultor Eletrônico



Kbase 6827: Getting info (tty, pid, environment vars) on UNIX into proc
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Getting info (tty, pid, environment vars) on UNIX into proc

920721-gfs01
INTRODUCTION:
=============
This Product Services Technical Support Knowledgebase entry
shows how to get information about a client session using the
PROGRESS 4GL. The same basic strategy can also be used to
read UNIX environment variables.

WHY YOU NEED TO DO THIS:
========================
To get information such as process id, tty port, login
time, tailored directories, from the operating system and to your
procedures.

PROCEDURAL APPROACH:
====================
The following PROGRESS procedure shows how to use UNIX and
the PROGRESS proshut utility to get this information.
Please note that this program will run only on the UNIX
operating system, and when a PROGRESS broker is running for
the database.

/**********************************************************/
/* PROGRAM NAME : whoami.p */
/* AUTHOR : gfs */
/* DESCRIPTION : Gets information about a client session */
/* from proshut (Written only for UNIX) */
/* LAST MODIFIED: 07/21/92 */
/**********************************************************/
DEF VAR userno AS INTEGER.
DEF VAR pid AS CHAR.
DEF VAR dow AS CHAR.
DEF VAR mo AS CHAR.
DEF VAR lday AS CHAR.
DEF VAR ltime AS CHAR.
DEF VAR lyear AS CHAR.
DEF VAR who AS CHAR.
DEF VAR tty AS CHAR FORMAT "X(10)".

UNIX SILENT echo 'x' | proshut demo | grep `whoami` > whoami.dat.
INPUT FROM whoami.dat NO-ECHO.
IMPORT userno pid dow mo lday ltime lyear who tty.
INPUT CLOSE.
UNIX SILENT rm whoami.dat.
DISPLAY userno LABEL "User" pid LABEL "Process"
dow + " " + mo + " " + lday + " " + lyear + " " +
ltime FORMAT "X(30)"
LABEL "Login Time" who LABEL "User Id" tty LABEL "Device".
/* END OF PROCEDURE */

The output of this procedure looks like this:

User Process Login Time User Id Device
---- ------- ------------------------ -------- ----------
1 4855 Tue Jul 21 1992 16:47:04 gfs /dev/ttyp5

Another approach is to read in the value of an environment variable,
such as those you set in your PROGRESS scripts, and then use that as
data in your procedure.

DEFINE VARIABLE dbdir AS CHAR FORMAT "X(50)".
UNIX SILENT echo $DBDIR > dbdir.loc.
INPUT FROM dbdir.loc.
IMPORT dbdir.
dbdir = dbdir + "/dbname".
CONNECT VALUE(dbdir).
RUN proc1.p.


ONLINE PROCEDURES OR UTILITIES:
===============================
proshut
grep (UNIX)

REFERENCES TO WRITTEN DOCUMENTATION:
====================================
System Administration General II

Progress Software Technical Support Note # 6827