Re: IP ADDRESS
- From: "Peter McMurray" <excalibur21@xxxxxxxxxxx>
- Date: Wed, 30 Jul 2008 23:05:03 GMT
Hi
I can see that the program is fine, I am just utterly confused as to why one
would be the least interesrted in doing it.
In the words of the inimitable Pauline "Please Explain"
Peter McMurray
"GlenB" <batchelg@xxxxxxxxxxxxx> wrote in message
news:8189c925-bfc5-4622-9603-ae4e536ad077@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The following code requires that you either don't have any of the
machines in DNS or RDNS, or that you have them all in DNS & RDNS. If
you are using it for identification only, you can create your own DNS
map in D3 and do the lookups yourself if you have a mixed/incomplete
DNS environment. The "REMOTE" in the call name is relative to the fact
that I'm asking Linux on the remote(server) side who the client side
is for a specific PIB. Enjoy!
SUBROUTINE GET.REMOTE.IP(REMOTE_IP)
NETWORK = "192.168.0.0"
!
! GET LINUX DEVICE NAME
!
PORT.NUM = SYSTEM(22)
EXECUTE 'LIST-LINES ':PORT.NUM CAPTURING OUTPUT
OUTPUT = OUTPUT<2>
CONVERT CHAR(32) TO CHAR(254) IN OUTPUT
LASTIDX = DCOUNT(OUTPUT,CHAR(254))
DEVID = OUTPUT<LASTIDX>
DEVID = SWAP(DEVID,"/dev/","")
!
! GET THE HOSTNAME FOR THE DEVICE
!
EXECUTE '!w -h' CAPTURING OUTPUT
LNS = DCOUNT(OUTPUT,CHAR(254))
IDX = 0
FOR PTR = 1 TO LNS
TLINE = OUTPUT<PTR>
CONVERT CHAR(32) TO CHAR(254) IN TLINE
LOCATE DEVID IN TLINE SETTING VM THEN
IDX = PTR
END
NEXT PTR
IF IDX > 0 THEN
WLINE = OUTPUT<IDX>
END ELSE
RETURN
END
CONVERT CHAR(32) TO CHAR(254) IN WLINE
LNS = DCOUNT(WLINE,CHAR(254))
IPCOL = 0
HOSTNAME = ''
FOR PTR = 1 TO LNS
IF WLINE<PTR> # "" AND IPCOL = 1 THEN
HOSTNAME = WLINE<PTR>
GO DONE
END
IF WLINE<PTR> = DEVID THEN
IPCOL = 1
END
NEXT PTR
STOP
DONE:
HOSTNAME = TRIM(HOSTNAME)
!
! DETERMINE IF HOSTNAME IS IP OR DNS RESOLVED HOSTNAME
! IF IT'S NOT AN IP, GET THE IP FROM LOCAL DNS
!
IPADDR = ''
IF HOSTNAME[1,3] # NETWORK[1,3] THEN
EXECUTE '!host ':HOSTNAME CAPTURING IPADDR
CONVERT CHAR(32) TO CHAR(254) IN IPADDR
LNS = DCOUNT(IPADDR,CHAR(254))
REMOTE_IP = IPADDR<LNS>
END ELSE
REMOTE_IP = HOSTNAME
END
RETURN
.
- Follow-Ups:
- Re: IP ADDRESS
- From: GlenB
- Re: IP ADDRESS
- From: Ross Ferris
- Re: IP ADDRESS
- References:
- IP ADDRESS
- From: LOIS
- Re: IP ADDRESS
- From: GlenB
- IP ADDRESS
- Prev by Date: Re: changing default justification
- Next by Date: Re: IP ADDRESS
- Previous by thread: Re: IP ADDRESS
- Next by thread: Re: IP ADDRESS
- Index(es):
Relevant Pages
|