MS DOS
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs MS DOS

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 27th, 2008, 06:37 PM
lunarpc2 lunarpc2 is offline
Registered User
Dev Archives Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 1 lunarpc2 User rank is Just a Lowly Private (1 - 20 Reputation Level)  
Time spent in forums: 22 m 11 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Web Development Archives FAQs MS DOS > Batch file help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT