The cscript below echos to the screen the list of PIDs only. Nothing else.
So it doesn't get any closer to solving the problem. -----Original Message----- From: Tony Gravagno <3xk547...@sneakemail.com> To: u2-users <u2-users@listserver.u2ug.org> Sent: Thu, Sep 6, 2012 6:48 pm Subject: Re: [U2] [Windows] Here are a number of ways to link a telnet client into UV back to its respective hostname. There's some redundancy here as not all commands work everywhere. OK, so as I understand the challenge, you got the inbound IP using System(42) (which of course should reveal the answer to life, the universe, and everything), and now you want the hostname of that PC. You can try all of the commands below and derive the solution from any command that returns valid data. You can't create a generic solution and guarantee success because the result of each command is dependent on site-specific configurations. There's NBTSTAT which requires NetBIOS but provides one vector to your solution. nbtstat -a 192.168.1.999 There's also PING: ping -a -n 1 192.168.1.999 This doesn't require DNS but I believe it does require WINS, and isn't always effective. If the IP is resolved the first non-blank line will have the hostname. There's also NSLOOKUP: nslookup 192.168.1.999 This checks your DNS, but if you're running DHCP it's not going to resolve. With a little .NET code you can also use the System.Net.Dns.GetHostByAddress method, then Execute SH to that routine with the IP. Now, if you are Not doing this from within Universe, you don't have an IP from System(42), so from what I gather you want to get the IP from a PID that represents a telnet client. NETSTAT -A will get you the hostnames and NETSTAT -N will get you the IP addresses. You can link those up using the client socket - while that's likely to be unique there's no guarantee. NETSTAT -O will get you the PID of the UV telnet server, not the client, with the hostname NETSTAT -ON will get you the server PID with the IP address. You can use 'TASKLIST /V | FIND "tl_server" ' to get the PIDs of clients that are telnetted into the UV server. Those PIDs agree with what you see in a LISTU and with the NETSTAT -O commands above. Change the find to "tl_service" to get the PID of the service. By matching the UV telnet service to a PID, the PID to an IP address or hostname, and the hostname to processes that are telnetted in, you sort of have a path to all of the info you need. Another way to link up the PID with the IP address for the tl_server is to execute the following script (join lines, intentionally broken to prevent wrapping): strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery( "Select * from Win32_Process Where NAME=""tl_server.exe""") For Each objItem in colItems Wscript.Echo objItem.ProcessId & ", " & objItem.CommandLine Next Save that into file uvclients.vbs. Then from the command line: cscript uvclients.vbs //nologo The output shows the PID from LISTU and the related IP address. (Note, you need scripting capability on the PC.) You can parse on that output if required once again to get the hostname from the IP. I'm sure none of that was helpful to WJ who will say "no, that's not it at all, what I really want is..." but I trust it will benefit someone else. T _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users -----Original Message----- From: Tony Gravagno <3xk547...@sneakemail.com> To: u2-users <u2-users@listserver.u2ug.org> Sent: Thu, Sep 6, 2012 6:48 pm Subject: Re: [U2] [Windows] Here are a number of ways to link a telnet client into UV back to its respective hostname. There's some redundancy here as not all commands work everywhere. OK, so as I understand the challenge, you got the inbound IP using System(42) (which of course should reveal the answer to life, the universe, and everything), and now you want the hostname of that PC. You can try all of the commands below and derive the solution from any command that returns valid data. You can't create a generic solution and guarantee success because the result of each command is dependent on site-specific configurations. There's NBTSTAT which requires NetBIOS but provides one vector to your solution. nbtstat -a 192.168.1.999 There's also PING: ping -a -n 1 192.168.1.999 This doesn't require DNS but I believe it does require WINS, and isn't always effective. If the IP is resolved the first non-blank line will have the hostname. There's also NSLOOKUP: nslookup 192.168.1.999 This checks your DNS, but if you're running DHCP it's not going to resolve. With a little .NET code you can also use the System.Net.Dns.GetHostByAddress method, then Execute SH to that routine with the IP. Now, if you are Not doing this from within Universe, you don't have an IP from System(42), so from what I gather you want to get the IP from a PID that represents a telnet client. NETSTAT -A will get you the hostnames and NETSTAT -N will get you the IP addresses. You can link those up using the client socket - while that's likely to be unique there's no guarantee. NETSTAT -O will get you the PID of the UV telnet server, not the client, with the hostname NETSTAT -ON will get you the server PID with the IP address. You can use 'TASKLIST /V | FIND "tl_server" ' to get the PIDs of clients that are telnetted into the UV server. Those PIDs agree with what you see in a LISTU and with the NETSTAT -O commands above. Change the find to "tl_service" to get the PID of the service. By matching the UV telnet service to a PID, the PID to an IP address or hostname, and the hostname to processes that are telnetted in, you sort of have a path to all of the info you need. Another way to link up the PID with the IP address for the tl_server is to execute the following script (join lines, intentionally broken to prevent wrapping): strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery( "Select * from Win32_Process Where NAME=""tl_server.exe""") For Each objItem in colItems Wscript.Echo objItem.ProcessId & ", " & objItem.CommandLine Next Save that into file uvclients.vbs. Then from the command line: cscript uvclients.vbs //nologo The output shows the PID from LISTU and the related IP address. (Note, you need scripting capability on the PC.) You can parse on that output if required once again to get the hostname from the IP. I'm sure none of that was helpful to WJ who will say "no, that's not it at all, what I really want is..." but I trust it will benefit someone else. T _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users