Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IP ADDRESS

12 views
Skip to first unread message

LOIS

unread,
Jul 24, 2008, 10:52:39 PM7/24/08
to
I WORK WITH D3 ON LINUX, I WANT TO GET MY IP ADDRESS DIRECTLY FROM D3.

CAN ANYONE HELP ME ???

THANKS.

Rookie

unread,
Jul 25, 2008, 8:00:56 AM7/25/08
to
Parse the results of a !netstat command.

!netstat -t --numeric-ports |grep 'yourD3ip:yourtelnetport#'

and the results would be like this:

tcp 0 9 1.1.2.162:5026
10.13.0.102:3184 ESTABLISHED

Cliff

unread,
Jul 28, 2008, 8:05:16 AM7/28/08
to

We are using AccuTerm so I wrote a VBScript to run the "ipconfig"
command and piped it to a file on the client's C drive.

Dim sDirectory As String
Dim WshShell As Object
Dim sWinDir As String

set WshShell = CreateObject("WScript.Shell")

sWinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
sDirectory = sWinDir

If Right(sDirectory,1) <> "\" Then sDirectory = sDirectory & "\

sDirectory = sDirectory & "System32\"
sDirectory = sDirectory & "ipconfig /all>c:\security.txt"

WshShell.Run("%comspec% /c " & sDirectory,0,True)

Another script is used to make a tab delimited file out of the
output. This is required so FTD works properly in the next step.

Dim oFSO As Object
Dim oFile As Object
Dim sText As String
Dim sOutput As String
Dim iX As Integer
Dim iCnt As Integer

Const forReading = 1, forWriting = 2, forAppending = 8

Set oFSO = CreateObject("Scripting.FileSystemObject")

set oFile = oFSO.OpenTextFile("C:\Security.txt",forReading,True)

sOutput = ""
iCnt = 0
Do Until oFile.AtEndOfStream
iCnt = iCnt + 1
sText = oFile.ReadLine
If sOutput = "" Then
sOutput = "Security" & Chr(9) & sText
Else
sOutput = sOutput & Chr(9) & sText
End If
Loop

oFile.Close

Sleep 2000

set oFile = oFSO.OpenTextFile("C:\Security.txt",forWriting,True)
oFile.WriteLine "*"
oFile.WriteLine sOutput
oFile.Close

Then we use FTD to import the file and parse the results

DATA "R"
DATA "K"
DATA "C:\SECURITY.TXT"
DATA ""
DATA "PORT":PORTNO
EXECUTE "FTD"

This allows us to keep track of the IP Address, MAC Address, and
Gateway of every log on session on the system.

Cliff

Symeon

unread,
Jul 30, 2008, 8:13:12 AM7/30/08
to
Dont know how you shell out a linux command on D3, but from linux you
can do who -m | awk '{print $6}' to get your current login session ip


Symeon.

GlenB

unread,
Jul 30, 2008, 11:04:39 AM7/30/08
to

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

Peter McMurray

unread,
Jul 30, 2008, 7:05:03 PM7/30/08
to
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" <batc...@bellsouth.net> wrote in message
news:8189c925-bfc5-4622...@8g2000hse.googlegroups.com...

Ross Ferris

unread,
Jul 30, 2008, 7:32:45 PM7/30/08
to
In days of old, for some of our "C" class security installations into
military and government departments, we used tol be able to lock
security down to a specific line, which in RS-232 days ran to a
specific location. So, if you were accessing SASPERS (the SAS
personnel system), even though you may have been a Colonel, or even a
General, there were just some things you couldn't access from insecure
locations.

When networks came about, using fixed IP's, you could approximate the
same sort of things --> even though your PIB may have floated, your IP
remained constant, so I'm guessing that perhaps this "IP knowledege"
may be built into some form of security system

Peter McMurray

unread,
Jul 30, 2008, 8:33:20 PM7/30/08
to
Hi Ross
Thanks. As you say we used to latch on to an address but that was so long
ago that I don't even think about it. Surely now that we have IP addresses
picked by the firewalls and connections that just come from anywhere , can
even be spoofed, as a method of security it has zero value. I appreciate
that a Qantas lounge might not be the best place to access SASPERS but if
one is going to leave the unencrypted cd of your battle plan in the drive
the IP address is the least of your worries :-)
I do know one company lost a sale through this sort of stupid behaviour. I
cannot remember whether it was Via or Hostaccess but when I went to the site
it decided that my IP address was false - it isn't I just have a hardware
firewall - and refused me access to so much as the manual.
The fact that several people have programmed solutions makes me wonder what
I am missing.
Peter McMurray
"Ross Ferris" <ro...@stamina.com.au> wrote in message
news:1f852b77-86ff-49cb...@j7g2000prm.googlegroups.com...

GlenB

unread,
Jul 30, 2008, 10:00:06 PM7/30/08
to

I don't follow you. If you want an application case, then consider a
workstation with 5 or 6 TCP based devices physically located at the
workstation with no programmatic connection to the client machine. In my
case I have 2 label printers, a scale, and a laser printer. When someone
goes to pack+ship an order, I don't want to force a specific user to be
logged in at that one station or to nail a specific PIB to that station.
Instead, I configured a station map that contains all of the workstation's
peripheral addresses and/or LPR devices based on the client machines IP
addresses. When anyone logs onto a specific workstation an identification
routine looks up the machine's IP and uses that to obtain the proper remote
devices map. Several different users could use any of the stations
(potentially in different SSH sessions on the same machine) and I can still
route the "data" where it needs to go and query the correct network scale
regardless of PIB/User/etc. There are other, possibly simpler, ways of
accomplishing this but this method seemed the most flexible and expandable
to me with the least amount of client machine configuration or programming.
Originally, I used the screen/window name from AccuTerm to determine
who-is-who and looked the map up that way. Unfortunately, it didn't work
100% of the time during extremely active testing and my subroutine often
chose the "Duh.. I dunno, use the default laser printer and the local label
printer" logic due to an invalid/chopped off/missing screen name.

Of course, application limitations could also be placed on the client
based on IP, subnet, or netmask. We don't have a need for that right now,
but it would be simple to implement with a client IP lookup tool similar to
this.

GlenB

"Peter McMurray" <excal...@bigpond.com> wrote in message
news:zs6kk.24252$IK1....@news-server.bigpond.net.au...

Peter McMurray

unread,
Jul 31, 2008, 1:05:26 AM7/31/08
to
Hi Glen
I have a user with offices all around the state. Sometimes the clerk in
Hobart is taking orders for printing at the unattended office in Ulverstone
for example - the drivers pop in and pick up the dockets when they are near
by. I have other sites with retail receipt printers etc. Sometimes the
printers are associated directly with a local machine and others that are
just on the network. When a user logs on I pick up the standard set of
devices that they use and that is their default however they can redirect
output to any printer on the system if they wish. All printers that are on
the network are shared through the Windows share procedures and the user
coldstart simply ties the share name to the D3 printer.

All programs that print have an Application print Queue name such as
INVOICE, RECEIPT, STANDARD etc that is linked through the application master
setup record to the appropriate queue. All Applications have a default
Master setup but this can be overridden for a particular logon or by the
actual user preparing the print or by the user when pulling it out of the
hold file. I differentiate between Laser Landscape, Laser Portrait,
DotMatrix, Local (eg receipt printer tied to a terminal) with the printer
definition. All printer jobs call a standard subroutine to create the files
required with the usual PRINT ON 1 PRINT ON 2 etc and a function key can
pull up the Print control program in any program - naturally I am not
leaving the user to battle with SP-EDIT etc. We also allow for different
invoice layouts from the same Invoice file so one printer may have Mobil
invoices on it and another may have the distributer's invoices on it.

So the only time one needs to know an IP address is when the printer is
first installed on the Windows Server and knowing the IP in D3 would be
pointless as one sends it to the share name. Of course printers could be
re-assigned in Windows with office re-arrangement but we are not interested
so long as the share name is correct - Oh Yes I forgot, we use DOSPrin for
windows printers such as MFC's and I have just remembered we have a server
in Melbourne but our 3 printers are in Sydney and I am not allowed access to
the server just my application.

Peter McMurray


"GlenB" <batchelg...@bellsouth.net> wrote in message
news:Z%8kk.1549$Ep1....@bignews2.bellsouth.net...

Andrew Kenna

unread,
Aug 3, 2008, 7:53:24 PM8/3/08
to
You can always use !ifconfig eth0 | grep ipaddr and figure the rest out from
there. that would give it to you on a nice clean line.

This is assuming eth0 is the device your looking for, if not change it to
the appropriate device name

"Rookie" <goo...@caspersonline.us> wrote in message
news:176ffea2-7b8d-4a48...@a2g2000prm.googlegroups.com...

Florida Dan

unread,
Aug 6, 2008, 12:44:14 PM8/6/08
to

EXECUTE "!w -h -s $LOGNAME | head -1 | tr -s ' ' | cut -d ' ' -f 3"

Assuming each user logs in with a different login

0 new messages