KpyM Telnet/SSH Server - Forum
Need to send a device identifier
Marius Visser Need to send a device identifier
 
Hi

I need to know if there are any way to send a device identifier (something like w1, 1 or 2234 for example) when logging onto the telnet server.

I need this device identifier to determine the screensize that the device logging on as, is using.

For instance I will have two handheld devices with different screen sizes that logs onto the telnet server. This device identifier is then passed into my console application as a parameter from the allusers.bat. the console app will then display the screen according to the device logged in.

Is this possible?


Kroum Grigorov
 
Hi,

If your devices are using static IPs you can identify them using %KTS_IP% environment variable.
Another solution is to use user name it is in %KTS_USER% variable.

Btw, if your device telnet client is smart enough it would send device screen size when initializing session. KTS will take care to resize console screen automatically, if this is the case you can directly check for console size in your app.

Kroum


Michael KTS_IP environment
 
Where is this KTS_IP environment variable? I also need to find out which device is associated with a telnet session. My devices all have static IPs. Thanks.

Michael


Kroum Grigorov
 
Just expand the KTS_IP variable.
For example you can see the KTS_IP value in cmd.exe by typing
echo %KTS_IP%
this will give you the ip of the connected user.
Combining this with a little batch scripting you can start different command or supply different parameters to commands based on the device ip.

Kroum


Michael Session Identifier
 
I guess my problem is that I am using only one user login to the KTS telnet server from several devices each running a telnet session (each device has a static ip). When I look at the task manager in Windows 2003 server, I see the same user with serveral instances of the application. I need to know which ip address or user is associated with each session. So if there is a way to use the %KTS_IP% variable, please give me an example. Thanks.

Michael


Kroum Grigorov
 
Since you are using one user for login you can't distinguish sessions by user name.

Here is what you can do:
1) you will need these third party tools(note openports is NOT free for commercial use)
openports.exe
pslist.exe

2) now using openports.exe you can get the list of open connections and the process that uses the connection

Code:

DiamondCS OpenPorts v1.0  (-? for help)
Copyright (C) 2003, DiamondCS - http://www.diamondcs.com.au/openports/
Free for personal and educational use only. See openports.txt for more details.

...
term.exe [752]
  TCP  192.222.235.2:8023     192.222.235.31:1036     ESTABLISHED
...

You are interested in the processes named "term.exe" these are KTS master session processes. In the sample above you have term.exe process (pid=752) connected to client with IP 192.222.235.31

3) run pslist.exe -t
this will give you tree view of running processes
Code:

PsList 1.23 - Process Information Lister
Copyright (C) 1999-2002 Mark Russinovich
Sysinternals - www.sysinternals.com

Process information for KPYM-L7FJWS28V3:

Name                             Pid Pri Thd  Hnd      VM      WS    Priv
Idle                               0   0   1    0       0      16       0
  System                           8   8  42  291    1672     224      28
    SMSS                         164  11   6   33    5256     420    1084
      CSRSS                      192  13  11  356   29992    2496    1368
      WINLOGON                   212  13  17  388   35928    3604    5920
        SERVICES                 240   9  34  522   36792    6100    3812
          telnetd                448   8   4   79   30716    1736    1832
            term                 752   8   1   38    9380    2512    1188
              CMD               1112   8   1   23    8892    1280     328
                NTVDM           1064   8   3   39   31336    2396    1368
...

you can find the above term.exe process by its pid(752), and as you see it has spawned two more programs CMD and NTVDM

Kroum


 

© 2007 - 2008 Kroum Grigorov
Powered by phpBB © 2001, 2005 phpBB Group