Computing.Net > Forums > Programming > Simple Batch File command help

Simple Batch File command help

Reply to Message Icon

Original Message
Name: Mini
Date: June 3, 2008 at 23:04:38 Pacific
Subject: Simple Batch File command help
OS: Windows XP
CPU/Ram: Windows XP Professional x
Model/Manufacturer: Dell
Comment:

Hi M2,
@echo off for /f "tokens=*" %%I in (IPlist) do call :pinger %%I goto :eof :pinger echo %TIME% >> pingLOG ping %1 >> pingLOG :: DONE

I am using the above batch file command to ping list of 60servers and works perfectly. But I need to generate two output files. one output file for Pingable server list and other output file for non-pingable server list. Can u please help


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: June 4, 2008 at 01:51:45 Pacific
Reply: (edit)

:: ping list and log dead / alive

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (IPlist) do (
ping %%a | find /i "reply" > nul
echo %time% >> !errorlevel!.log
echo %%a >> !errorlevel!.log
)


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: Mini
Date: June 5, 2008 at 20:36:47 Pacific
Reply: (edit)

Hi M2,

Thanks for your reply. This command works perfectly for me. But I can see out put file names as '0' and '1'.can you please help me how to give the output file name as 'Pingable'and 'Non-pingable'.

Thanks for you help
Mini


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: June 6, 2008 at 06:41:50 Pacific
Reply: (edit)

@echo off > 0.log & @echo off > 1.log
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (IPlist) do (
ping %%a | find /i "reply" > nul
echo %time% >> !errorlevel!.log
echo %%a >> !errorlevel!.log
)

type 0.log >> Pingable
type 1.log >> Non-pingable


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 4
Name: Mini
Date: June 8, 2008 at 19:35:48 Pacific
Reply: (edit)

Hi M2,

I have replaced 0.log with pingable.log and 1.log with Non-pingable.log but after that when I run the file I can see 4 logs created.Pingable and non-pingable logs are empty and 0 and 1 logs are showing the results..
Please help me to get only 2 logs pingable and non-pingable and correct results in that output logs..


@echo off > pingable.log & @echo off > Nonpingable.log
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (C:\test.txt) do (
ping %%a | find /i "reply" > nul
echo %time% >> !errorlevel!.log
echo %%a >> !errorlevel!.log
)


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: June 8, 2008 at 21:14:19 Pacific
Reply: (edit)

If it bothers you to have 0.log & 1.log left just end the bat with:

del ?.log


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal


Response Number 6
Name: Mini
Date: June 9, 2008 at 20:04:36 Pacific
Reply: (edit)

My query is to get only 2 output logs with Names "Pingable"and "Non-Pingable" and appropriate results in the same logs.


Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: June 10, 2008 at 00:38:41 Pacific
Reply: (edit)

@echo off > 0.log & @echo off > 1.log
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (IPlist) do (
ping %%a | find /i "reply" > nul
echo %time% >> !errorlevel!.log
echo %%a >> !errorlevel!.log
)

type 0.log >> Pingable
type 1.log >> Non-pingable

del ?.log


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 8
Name: Mini
Date: June 10, 2008 at 22:07:02 Pacific
Reply: (edit)

THANKS A LOT M2..:) This works perfectly for me..
Thanks again


Report Offensive Follow Up For Removal

Response Number 9
Name: Mini
Date: June 10, 2008 at 22:10:57 Pacific
Reply: (edit)

Hi M2,

One more small query..

I need bacth file command for check the list of URL's.
Like I have some list of URL's to check daily if they are up or not..So Can I check it using Batch file??

Please help me..


Report Offensive Follow Up For Removal

Response Number 10
Name: Mechanix2Go
Date: June 11, 2008 at 03:57:03 Pacific
Reply: (edit)

Do you mean to ping them?


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 11
Name: Mini
Date: June 11, 2008 at 18:44:32 Pacific
Reply: (edit)

Yes, I want to check If the URL's are working or not..


Report Offensive Follow Up For Removal

Response Number 12
Name: Mechanix2Go
Date: June 12, 2008 at 10:48:42 Pacific
Reply: (edit)

You can ping a domain like:

www.kitco.com

but you can't ping a URL like:

http://www.kitco.com


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Simple Batch File command help

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge