Simple for command to get ping results output to file...

G

Guest

Ok, so I write this fairly simple line:
for /f "delims= tokens=1" %%A in (Printers.txt) do Ping %%A >>PingPrinter.txt

Printers.txt has a list of printer names in it and I can ping most of them
fine (I want to see which ones aren't pinging, hence the output to file).
But all I get in the output file is:
I:\Scripts\PrinterQ>for /F "delims= tokens=1" %A in (Printers.txt) do Ping
%A 1>>PingPrinter.txt
I:\Scripts\PrinterQ>Ping eqrdrp02001 1>>PingPrinter.txt
I:\Scripts\PrinterQ>Ping eqrprn_col_pdf 1>>PingPrinter.txt
I:\Scripts\PrinterQ>Ping eqrprn04001 1>>PingPrinter.txt
and so on...
In the dos box it says:
"The process cannot access the file because it is being used by another
process."

If I change the DO statement to something like @Echo Name: then I get a list
of the printer names in the output file.

Any ideas what could be going wrong?
 
F

foxidrive

Ok, so I write this fairly simple line:
for /f "delims= tokens=1" %%A in (Printers.txt) do Ping %%A >>PingPrinter.txt

Printers.txt has a list of printer names in it and I can ping most of them
fine (I want to see which ones aren't pinging, hence the output to file).
But all I get in the output file is:
I:\Scripts\PrinterQ>for /F "delims= tokens=1" %A in (Printers.txt) do Ping
%A 1>>PingPrinter.txt
I:\Scripts\PrinterQ>Ping eqrdrp02001 1>>PingPrinter.txt
I:\Scripts\PrinterQ>Ping eqrprn_col_pdf 1>>PingPrinter.txt
I:\Scripts\PrinterQ>Ping eqrprn04001 1>>PingPrinter.txt
and so on...
In the dos box it says:
"The process cannot access the file because it is being used by another
process."

If I change the DO statement to something like @Echo Name: then I get a list
of the printer names in the output file.

Any ideas what could be going wrong?

Did you have two windows open with the process happening in both windows?

If not, try changing the filename.
 
G

Guest

Actually I had been stupid enough to call the batch file 'ping.cmd' so
instead of using ping.exe it was trying to call itself...
I felt very silly when I realised...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top