'who am i' from unix 
Author Message
 'who am i' from unix

Hi !

How can i get the result to the cobol of the command 'who am i' from unix ?
any ideas ?

TIA

Paulo



Sat, 05 May 2001 03:00:00 GMT  
 'who am i' from unix

Quote:

> Hi !

> How can i get the result to the cobol of the command 'who am i' from unix ?
> any ideas ?

> TIA

> Paulo


The only way we ever got it to work was to redirect the output from 'who
am i' to a file.
Then you can define a line-sequential file in your cobol program, read
in your data,
and away you go.

--

The opinions expressed here are not those of my employer, unless he
happens to be right.



Sat, 05 May 2001 03:00:00 GMT  
 'who am i' from unix
I once did this with AcuCOBOL.

CALL "SYSTEM" USING "who am i > /usr/support/whoisuser".
OPEN INPUT WHO-USER.
READ WHO-USER NEXT AT END CONTINUE.

Then I used a character reference and presto!.

Quote:

>Hi !

>How can i get the result to the cobol of the command 'who am i' from unix ?
>any ideas ?

>TIA

>Paulo




Sat, 05 May 2001 03:00:00 GMT  
 'who am i' from unix

Quote:

> Hi !

> How can i get the result to the cobol of the command 'who am i' from unix ?
> any ideas ?

What compiler, what version?

In RM/COBOL you can easily add a routine to the runtime interpreter and then
CALL "LOGNAME" USING MY-NAME.

Regards
Albert Ratzlaff



Sun, 06 May 2001 03:00:00 GMT  
 'who am i' from unix
We have an environment variable set up as:

       LOGNAME=`whoami`; export LOGNAME

automatically when each user logs in. Then we have a program that basically
does the following:

       display "LOGNAME" upon environment-name.
       accept w-user from environment-value.

Then from any program just:

       call "GETUSER" using w-user.
       cancel "GETUSER".

We Use MF COBOL 4.1, so whether this will work in other compilers I am not
sure.

Regards
Mathew



Quote:
>Hi !

>How can i get the result to the cobol of the command 'who am i' from unix ?
>any ideas ?

>TIA

>Paulo




Sun, 06 May 2001 03:00:00 GMT  
 'who am i' from unix

Quote:


> > Hi !

> > How can i get the result to the cobol of the command 'who am i' from unix ?
> > any ideas ?

> > TIA

> > Paulo

> The only way we ever got it to work was to redirect the output from 'who
> am i' to a file.
> Then you can define a line-sequential file in your cobol program, read
> in your data,
> and away you go.

If you are using Micro Focus COBOL, you can set up a pipe to do this
using the
DD_ filename mapping mechanism.
Try something line:

SELECT PIPEFILE ASSIGN "PIPE"
    ORGANISATION LINE-SEQUENTIAL
    .

DATA DIVISION.
FILE SECTION.
FD PIPEFILE.
01 PIPELINE PIC X(80).

PROCEDURE DIVISION.
    DISPLAY "DD_PIPE" UPON ENVIRONMENT-NAME *> map the file "PIPE"
    DISPLAY "<who am i" UPON ENVIRONMENT-VALUE *> The command to exec
    OPEN INPUT PIPEFILE
    READ PIPEFILE *> only one line expected ...
    CLOSE PIPEFILE
    DISPLAY PIPELINE
    .

Normally, DD_ mapping just maps one filename to another.
However, you can use '<' as a leading character to read the stdout of a
shell command (OPEN INPUT file), '>' to write to the stdin of a shell
command (OPEN OUTPUT file) or '|' to access both stdin and stdout of a
shell command (OPEN IO file). You can't access the stderr unless you
merge it with stdout on the shell command line (using "2>&1").

Cheers, Kev.



Mon, 07 May 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. GNAT on 'Digital Unix (formerly OSF)'

2. (UNIX) Environment variables and 'system'

3. 'BUS ERROR' of FORTRAN on UNIX

4. Using '*'in exec command on UNIX

5. : Background execution stops at 'exec' (UNIX)

6. corresponding tcl command for UNIX 'touch'

7. Newbie:'Entry' echo problem Unix/Win95

8. Front end to unix command 'find'

9. simulating Unix 'more' in Tcl

10. stream('file','c','seek ='x) problem

11. Wanted: Hints'n'Tips'n'Bits'n'Bobs

12. There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand

 

 
Powered by phpBB® Forum Software