Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for getports.pl

(view source code of getports.pl as plain text)

  1. #! perl
  2.  
  3. if ( $ARGV[0] ) {
  4. 	print "\nGetPorts.pl,  Version 1.00 for DOS, Windows & OS/2\n",
  5. 	      "Display port addresses of parallel and serial ports\n\n",
  6. 	      "Usage:  GETPORTS.PL\n\n",
  7. 	      "This script uses DEBUG.EXE to read the information from base memory.\n",
  8. 	      "Tested in Windows 2000 only.\n\n",
  9. 	      "Written by Rob van der Woude\n",
  10. 	      "http://www.robvanderwoude.com\n\n\n",
  11. 	      "Your ports info:\n";
  12. }
  13.  
  14. print( "\n" );
  15.  
  16. ## Create temporary DEBUG script
  17. $dbg = "D 40:0 L E\nQ\n";
  18. open( DBGSCR, "> getports.dbg" ) || die( "Cannot open temporary DEBUG script: $!" );
  19. print DBGSCR $dbg;
  20. close DBGSCR;
  21.  
  22. ## Run DEBUG script and store output in array
  23. @portsdbg = split( /([-,\s])/,`debug.exe < getports.dbg | find "  "` );
  24.  
  25. ## Format and display the result
  26. for ( $c = 1; $c < 5; $c++ ) {
  27. 	print( "COM$c=@portsdbg[4*$c+2]@portsdbg[4*$c]\n");
  28. }
  29. for ( $c = 1; $c < 4; $c++ ) {
  30. 	print( "LPT$c=@portsdbg[4*($c+4)+2]@portsdbg[4*($c+4)]\n");
  31. }
  32.  
  33. ## Delete temporary DEBUG script
  34. `DEL getports.dbg >NUL 2>&1`;
  35.  

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