Copyright © 2003-2010 by Prof. Timo Salmi  
Last modified Sun 24-Oct-2010 13:18:18
Welcoming the user from
On Thu 13-Dec-2018 10:34:06 local time

Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.

133} How do I get the current IP address, number and name?

  @echo off & setlocal enableextensions
  :: Test first

  ipconfig|find "IP Address">nul
  if %errorlevel% GTR 0 (
    echo Not connected
    goto :EOF)
  :: Get the current IP

  for /f "tokens=2 delims=:" %%i in (
    'ipconfig /all^|find "IP Address"'
    ) do set ip=%%i
  set ip=%ip: =%
  echo %ip%
  :: Look up the IP address on the name server

  for /f "tokens=2 delims=:" %%n in (
    'nslookup %ip%^|find "Name:"'
    ) do set name=%%n
  set name=%name: =%
  echo %name%
  endlocal & goto :EOF

The output might be e.g.
  Not connected

This extra part is not NT/2000/XP/.. CMD.EXE scripting but PHP (Hypertext preprocessed file) programming. It is, however, of interest for this particular item. If you look at the welcoming header box of the current page, you will observe your remote IP-information (and the date/time). The PHP code used is
  $today = getdate();
  $datetimen = substr($today[weekday],0,3) . " " . $today[mday] . "-" . substr("$today[month]",0,3) . "-" . $today[year] . " " . substr("00$today[hours]",-2) . ":" . substr("00$today[minutes]",-2) . ":" .substr("00$today[seconds]",-2);

    <TR STYLE="background: #99FFCC">
        <FONT SIZE="-1">
        Welcoming the user from <?php echo $remoteaddr; ?><BR>
        <?php echo $remotename; ?><BR>
        <?php echo $servername; ?><BR>
        On <?php echo $datetimen; ?> local time

  W3Schools PHP Tutorial
  The PHP Group PHP Manual