1.

Solve : NEED TO KHOW N/W CONNECTIVITY?

Answer»
HI all
(NEED SCRIPT)

I am using Windows xp OS and need help on a two simple issues. I'll really appreciate if you can help me.

Issue 1. I want to ping an IP address continuosly and log the ping results as text file. If it is possible, I want to execute both commands(ping and log) in the same line. What would be the correct command syntax? (I MEAN I need to execute both ping and log with one "ENTER")

PS: I have to see the ping REPLY packets on the screen while it is being logged at the same time.

Issue 2. I need to ping 20 IP addresses on 20 command line windows at the same time, log the ping results as well. In other words I need to do Issue one on 20 windows and 20 IP addresses. Could you help me how to create a script about do Issue 2 with one command?

command line window 1: pings and logs 172.17.48.2,
command line window 2: pings and logs 172.17.49.2,
...
...
command line window 10: pings and logs 172.17.48.66

Thank in advance for helping SmileyNot sure I understand all this. Are you using one logfile for all the pings? You want to have 20 separate windows open all running a ping?

You can run one ping and log the results with redirection: ping -n 1 127.0.0.1 >> log.txt

By preceding the ping with a start command, you trigger off many pings all running in separate windows.

Problem: Text files cannot be shared by multiple processes; Once one process opens the log file, all others will be locked out and the each ping will fail.

Perhaps if you could tell us what you're trying to accomplish, we could find another approach. If you want output both on the console and logged to a file, you may need to use one of the Windows scripting languages.

8-)Whats a ping??
For issue 1, I don't know of a way to log to file AND screen without an external utility. You can get the TEE.EXE command from http://unxutils.sourceforge.net/ and then you could use something like:
Code: [Select]ping -t 127.0.0.1 |tee ping.log
For issue 2, you could replace the real IP address in the parenthesis and do something like this in a batch file:
Code: [Select]@echo off
for %%a in (172.17.48.2 172.17.49.2 172.17.48.3 172.17.48.4 172.17.48.5) do (
echo ping %%a ^> Ping%%a.log >%%a.bat
echo del %%0 2^> NUL ^&exit>>%%a.bat
start %%a.bat
)
If all the IP addresses are in a row (or some pattern) you could change your for loop to automate the generation of the numbers.


Discussion

No Comment Found