|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Batch file help
Hi,
Below is my batch file. It reads a txt file that has IP addresses, pings the address and puts the results of the first line of the ping response into another file. It reads the second file and takes out the computername and IPaddress and puts that into a third file. Then to boot, for some reason the variable that holds the IP address from the first file does not work in the ping command, so I've used a different variable. 1) I can't figure out how to put the ping results into a variable and have the For /F read that variable instead of the file. 2) I don't know how to make the ping command take the %Machine variable instead of the %1. 3) How can I get rid of the brackets around the IPAddr. in the results.txt file? Thanks in advanced for your help. ________________________________________ @ECHO OFF TITLE IP Address to Computer Name REM ----------------------------------- REM SET MachineList=names.txt SET ResultsFile=results.txt REM REM ----------------------------------- CLS ECHO. IF NOT EXIST "%MachineList%" ( ECHO Cannot locate Machine List: %MachineList% PAUSE>NUL GOTO :EOF ) ECHO Processing all machine names in %MachineList% . . . rem ECHO. FOR /f "tokens=*" %%M in (%MachineList%) do CALL :CHECK "%%M" GOTO :EOF :CHECK SET Machine=%~1 SET Machine=%Machine: =% PING -a -n 1 -w 1000 %1 | Find "Pinging" > ip1.txt FOR /F "tokens=2,3 delims= " %%A IN (ip1.txt) DO Echo %%A, %%B >> %ResultsFile% EXIT /B :EOF |
![]() |
| Viewing: Web Development Archives > FAQs > MS DOS > Batch file help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|