Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for hostname.cmd

(view source code of hostname.cmd as plain text)

  1. /* What is the host name for this IP address? */
  2.  
  3. trace off
  4. say
  5.  
  6. parse arg ipaddress dummy
  7. ipaddress = strip( ipaddress )
  8. if ipaddress =  "" then call Syntax
  9. if dummy     <> "" then call Syntax
  10. if pos( "?", ipaddress ) > 0 then call Syntax
  11. parse value ipaddress with digit.1"."digit.2"."digit.3"."digit.4
  12. do i = 4 to 1 by -1
  13. 	if digit.i                  =  "" then call Syntax
  14. 	if datatype( digit.i, "W" ) <>  1 then call Syntax
  15. 	if digit.i                  <   0 then call Syntax
  16. 	if digit.i                  > 255 then call Syntax
  17. end
  18.  
  19. qname = rxqueue( "CREATE" )
  20. address CMD "@TRACERTE "||ipaddress||" 2>&1 | RXQUEUE /FIFO"
  21. do until queued( ) = 0
  22. 	parse pull line
  23. 	if pos( "(", line ) > 0 then do
  24. 		if word( line, 3 ) = "("||ipaddress||")" then do
  25. 			say word( line, 2 )
  26. 		end
  27. 	end
  28. end
  29. call rxqueue "DELETE", qname
  30. EXIT 0
  31.  
  32.  
  33. Syntax: procedure
  34. 	say "HostName,  Version 1.02 for OS/2"
  35. 	say "Retrieves the host name for a specified IP address"
  36. 	say "Written by Rob van der Woude"
  37. 	say "http://www.robvanderwoude.com"
  38. 	say
  39. 	say "Usage:  HOSTNAME  <IP_address>"
  40. 	EXIT 1
  41. return
  42.  

page last modified: 2024-04-16; loaded in 0.0156 seconds