How to get local IP adress | Uniface 9 | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

—  Results per page  —








— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters
For a group of consecutive words like 'end of support' use Match phrase

sp_Feed Topic RSS sp_TopicIcon
How to get local IP adress
24 Sep 2018
10:11 am
Avatar
dammie
Member
Forum Posts: 86
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hello,

is there way I can get ip adress of client computer that is running uniface form application via proc/function statement?

Thanks for hints

dammie

24 Sep 2018
11:08 am
Avatar
ulrich-merkel
Frankfurt/Germany
Member
Forum Posts: 1868
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline
  • activate OS.commandout(“ipconfig”,$result)
  • You’ll see a bunch of information, but the line you want to look for is “IPv4 Address.”
24 Sep 2018
12:50 pm
Avatar
dammie
Member
Forum Posts: 86
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Is there any other way? — for some security reason os command implementaion is not available for user of application…

24 Sep 2018
1:58 pm
Avatar
ulrich-merkel
Frankfurt/Germany
Member
Forum Posts: 1868
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

There are some tiny JAVA programs documented:

https://beginnersbook.com/2014/07/java-program-to-get-ip-address/

export it as “junnable JAR”, and you can start it with:

spawn “#javaw -jar my_jar_file”

 

Another option inside Uniface would be (with a temp creation of the <$componentname>.bat):

entry do_launch
params
string p_formname : out
endparams
spawn “#<$componentname>.bat”
; ipconfig > TEST1.out
fileload “<$componentname>.out”, p_formname
end ; do_launch

HIH, Uli 

24 Sep 2018
6:42 pm
Avatar
Knut
Member
Forum Posts: 224
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

$settings accesses registry settings –> HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces

There are two or three keys here – you’ll probably have to search each for ‘DhcpServer’ – if that sub key
is present, the ‘real’ IP address for the PC will be in ‘DhcpIPAddress’.

Good luck.

Knut

25 Sep 2018
8:46 am
Avatar
ulrich-merkel
Frankfurt/Germany
Member
Forum Posts: 1868
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hi Knut,

a very nice solution without any implementations outside the uniface world.
Think I should read a little more about the contents of the Windows Registy.

Greetings from a very cold Frankfurt/Main morning (5° C),
Uli

25 Sep 2018
10:41 am
Avatar
Arjen van Vliet
Member
Forum Posts: 184
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

My approach would be:
1. use ipconfig (in DOS box) to obtain your ip address (in my case 172.16.38.124)
2. Search the HKEY_LOCAL_MACHINE in regedit for that value to come up with the keys that Knut mentions already from the top of his mind.
3. Read the Uniface documentation on how to craft something, using $setting.

More background on the use of $setting to obtain registry values (click-able link):
Uniface Reference > Proc: Functions > $setting > Addressing Registry Keys with $setting

(Does anybody know how stable these registry keys are; do they change over time?)

01 Oct 2018
5:15 pm
Avatar
gianni
Member
Forum Posts: 343
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Arjen van Vliet said

1. use ipconfig (in DOS box) to obtain your ip address (in my case 172.16.38.124)
… 

Is it that simple? Not really in my experience…
The simple case scenario (IPv4): one network card = one IP and one gateway
The worst case scenario (IPv4 or IPv6): +network cards = +IPs and +one or more gateways to deal with [it is becoming the normal scenario with Ethernet + WiFi + Bluetooth + VPN(s) + …]

After installing “Unix Utilities” (GnuWin32) into your Windows machine the command could be:
C:\> ipconfig | grep IPv4 | awk “{print $NF}”
This command could report one or more IP in the link-local range 169.254.0.0/16; these IP(s) could simply be discarded.
The same approach should work for IPv6, remembering to discard those in the link-local range FE80::/10.
C:\> ipconfig | grep IPv6 | awk “{print $NF}”

A refined approach for IPv4 should consider in parallel with each IP(s) the default gateway associated to with command:
C:\> ipconfig | grep Gateway | awk “{print $NF}”
Only network card(s) associated with a real gateway are able to send net traffic to the outside world.
Gateways AFAIK are automatic on IPv6.
Which part of the “world” sits behind each gateway in a complex network, it could be difficult to recognize…

Some of these rules should be applied also if Windows registry is inpected using $setting().

Hope it helps…

Gianni

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 131

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ulrich-merkel: 1868

Iain Sharp: 674

Theo Neeskens: 366

gianni: 343

Adrian Gosbell: 318

istiller: 296

rogerw: 272

Knut: 224

lalitpct: 197

Arjen van Vliet: 184

Member Stats:

Guest Posters: 3

Members: 10312

Moderators: 0

Admins: 6

Forum Stats:

Groups: 1

Forums: 62

Topics: 2294

Posts: 9946

Newest Members:

glennarm2, Punsnxu, Kevinshamp, CliffInali, janicetupct88, murielfo3, paulpn16, KreditovichHaist, evangelinerr2, janicetupsh87

Administrators: admin: 23, diseli: 1028, Nico Peereboom: 84, richiet: 406, Mike Taylor: 35, JanCees: 38