Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get the users ip address

Status
Not open for further replies.

butler

MIS
Oct 12, 1998
88
0
0
US
I'm using microfocus on a unix platform. How do i get the ip address of the users?

Thanks
--bill
 
Depends on the Unix flavor, and it is better to put this question on a Unix forum.

Look at the following commands, and output this to a file, and then read the file on a COBOL program.

Who
finger


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Assumption time! I assume that you know the command to obtain the ip number.

I'll past come code pieces which will give you enough info to figure it out. What I do is count the number of *.txt files in a given directory:
Code:
FILE-CONTROL.
      SELECT CMD-LS       ASSIGN   TO W-CMD-LS,
                          FILE STATUS W-CMD-FS,
                          ORGANIZATION IS LINE SEQUENTIAL.
.
.
FILE SECTION.
  01  CMD-LS-REC.
       03 FILLER       PIC X(128).
.
.
MOVE SPACE TO W-CMD-LS.
STRING "<ls -F1"                    DELIMITED BY SIZE
        SPACE                       DELIMITED BY SIZE
       "/home/thegreatest/*.txt"    DELIMITED BY SIZE
        SPACE                       DELIMITED BY SIZE
       "| grep -v / | wc -l"        DELIMITED BY SIZE
    INTO W-CMD-LS END-STRING.
OPEN INPUT CMD-LS.
READ       CMD-LS.
COMPUTE FILE-COUNT =  FUNCTION NUMVAL (CMD-LS-REC).
CLOSE      CMD-LS.
As you can see you build you shell command as a file-name. The first char "<" does the trick.

(This is no standard COBOL. It is Micro Focusish on unix)
 
Thanks Truusvlugindewind!

That is slick!

--bill
 
Ok, I tried out the above code in your example and it runs clean, but CMD-LS-REC comes back empty!

:(
 
I wonder:
What do you see when you display the content of W-CMD-LS after building it with STRING?
What do you get after executing the same string (starting from postion 2) in a you normal shell?

That's the way to test such a structure.

NB: I hope you realise it's example code. It will only work when you log on to your unix system as user "thegreatest" and when you have files in you home dir ending with "txt".
You do realise??
 
Thanks Truusvlugindewind,

I did chane the W-CMD-LS content to be relative to my unix system, and when I loked at it in the debugger it was built correctly, and executed correctly at the unix prompt.

As a work around, I ended up modifying the system wide login script to create an environment variable with the users IP in it and then I read the variable from within the program. It works but I like your code better if I can get it to work!

--bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top