Une boucle avec la command PING
Moderator: DosItHelp
Une boucle avec la command PING
Bonjour,
Voilà je cherche un script qui me permet de copier les adresses IP dans un fichier txt si ils répondent aux PI
Le BUT :
1- Les noms des sites : aaa.com bbb.net ccc.org ...
2- Nom du fichier test.txt
3- ET le résultat dans le formulaire ci-dessous :
xxx.xxx.xxx.xxx:aaa.com:
yyy.yyy.yyy.yyy:bbb.net:
zzz.zzz.zzz.zzz:ccc.org:
...
Merci.
Voilà je cherche un script qui me permet de copier les adresses IP dans un fichier txt si ils répondent aux PI
Le BUT :
1- Les noms des sites : aaa.com bbb.net ccc.org ...
2- Nom du fichier test.txt
3- ET le résultat dans le formulaire ci-dessous :
xxx.xxx.xxx.xxx:aaa.com:
yyy.yyy.yyy.yyy:bbb.net:
zzz.zzz.zzz.zzz:ccc.org:
...
Merci.
Re: Une boucle avec la command PING
Sorry, but I don't understand French. I used the google translator to perceive your question. Please ask in English next time (like everybody does in that forum).
Not quite sure but I guess this is what you were talking about:
Regards
aGerman
Not quite sure but I guess this is what you were talking about:
Code: Select all
@echo off &setlocal
>"test.txt" (
for %%i in (
aaa.com
bbb.net
ccc.org
) do (
for /f "tokens=2 delims=[]" %%j in (
'ping -n 1 %%i 2^>nul^|findstr "..*\[[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\]..*"'
) do echo %%j:%%i:
)
)
Regards
aGerman
Re: Une boucle avec la command PING
alid0381, rien de personne parle francais sur le forum, mais je le parle un peu
Just to check, is this what you got from your translation, aGerman? (Google Translate is notorious for errors)
Not sure what PI means..
alid0381 ! Est-ce que tu sais comment on dit 'PI' en anglais svp ?
Merci
Phillid
Just to check, is this what you got from your translation, aGerman? (Google Translate is notorious for errors)
alid0381 wrote:Hello,
I'm trying to find a script that lets me to copy the IP addresses in a text file if they match PI
The Request:
1 - The names of the sites: ...
2 - Name of the text file: ...
3 - And the result in the layout just below:
xxx.xxx.xxx.xxx:aaa.com:
yyy.yyy.yyy.yyy:bbb.net:
zzz.zzz.zzz.zzz:ccc.org:
Thanks
Not sure what PI means..
alid0381 ! Est-ce que tu sais comment on dit 'PI' en anglais svp ?
Merci
Phillid
Re: Une boucle avec la command PING
Thanks phillid. That's more or less what I translated. PI "could" be short for par intérim. I assume it means someting like "... if (ping was) successful".
Regards
aGerman
Regards
aGerman
Re: Une boucle avec la command PING
hhhh...
Thanks to aGerman and phillid
Thanks to the team
There is a mistake : Not 'PI' But 'IP'
I do not speak English
I create a small program to write the IP addresses in a txt file in the form
xxx.xxx.xxx.xxx:aaa.com:
@echo off
mode 14,1&color 1e
set /a a = 254
set /a b = 254
set /a c = 254
set /a d = 250
:aa
IF %a% LEQ 255 (
IF %b% LEQ 255 (
IF %c% LEQ 255 (
IF %d% LEQ 255 (
echo %a%.%b%.%c%.%d%:e:>>"IP.txt"
set /a d = %d% + 1&goto aa
) ELSE (
set /a c =%c% + 1&set /a d = 250&goto aa
)
) ELSE (
set /a b =%b% + 1&set /a c = 254&goto aa
)
) ELSE (
set /a a =%a% + 1&set /a b = 254&goto aa
)
) ELSE (
EXIT
)
But the problème
...%d%:e:
how to create a batch file (*. bat) for each IP address to its site; if it exist!
Exemple
193.52.104.60:forum.ubuntu-fr.org:
74.125.230.196:google.com:
....
Thanks to aGerman and phillid
Thanks to the team
There is a mistake : Not 'PI' But 'IP'
I do not speak English
I create a small program to write the IP addresses in a txt file in the form
xxx.xxx.xxx.xxx:aaa.com:
@echo off
mode 14,1&color 1e
set /a a = 254
set /a b = 254
set /a c = 254
set /a d = 250
:aa
IF %a% LEQ 255 (
IF %b% LEQ 255 (
IF %c% LEQ 255 (
IF %d% LEQ 255 (
echo %a%.%b%.%c%.%d%:e:>>"IP.txt"
set /a d = %d% + 1&goto aa
) ELSE (
set /a c =%c% + 1&set /a d = 250&goto aa
)
) ELSE (
set /a b =%b% + 1&set /a c = 254&goto aa
)
) ELSE (
set /a a =%a% + 1&set /a b = 254&goto aa
)
) ELSE (
EXIT
)
But the problème
...%d%:e:
how to create a batch file (*. bat) for each IP address to its site; if it exist!
Exemple
193.52.104.60:forum.ubuntu-fr.org:
74.125.230.196:google.com:
....
Re: Une boucle avec la command PING
This is untested: it tests the ping by the IP address, not the domain. Change ping %1 to ping %2 to test the domain name and DNS resolution
Code: Select all
@echo off
type nul>pass.txt
type nul>fail.txt
for /f "tokens=1,2 delims=:" %%a in (IPlist.txt) do call :ping %%a %%b
goto :EOF
:ping
echo testing %1:%2
ping %1|find /i "TTL=">nul
if %errorlevel%==0 >>pass.txt echo %1:%2&echo pass
if %errorlevel%==1 >>fail.txt echo %1:%2&echo FAIL
Re: Une boucle avec la command PING
Thanks foxidrive
it's a good idea
But in the txte pass.txt There are :
google.com:
I changed in the line: "if %errorlevel%==0 >>pass.txt echo :%1:%2&echo pass" %1=>>:%1 ( means ) google.com: =>> :google.com:
What is the way to find in the txte pass.txt : 74.125.230.193:google.com:
it's a good idea
But in the txte pass.txt There are :
google.com:
I changed in the line: "if %errorlevel%==0 >>pass.txt echo :%1:%2&echo pass" %1=>>:%1 ( means ) google.com: =>> :google.com:
What is the way to find in the txte pass.txt : 74.125.230.193:google.com:
Re: Une boucle avec la command PING
The code he wrote is supposed to have both IP and domain name as parameters in order to echo them both.
%1 and %2 are CL parameters.
foxidrive wrote:Code: Select all
if %errorlevel%==0 >>pass.txt echo %1:%2&echo pass
if %errorlevel%==1 >>fail.txt echo %1:%2&echo FAIL
%1 and %2 are CL parameters.
Re: Une boucle avec la command PING
Now
my colleague Fawers
I know the site, that in IPlist.txt
I also can get the IP from the command PING
All of these data supposed.
my colleague Fawers
I know the site, that in IPlist.txt
I also can get the IP from the command PING
All of these data supposed.
Re: Une boucle avec la command PING
Perhaps you didn't understand what I meant?
CL Parameters = command line parameters.
If you already have the IP list along with their respective domain names, you just have to run foxi's code with them.
alid0381 wrote:Now
my colleague Fawers
I know the site, that in IPlist.txt
I also can get the IP from the command PING
All of these data supposed.
alid0381 wrote:But in the txte pass.txt There are :
google.com:
I changed in the line: "if %errorlevel%==0 >>pass.txt echo :%1:%2&echo pass" %1=>>:%1 ( means ) google.com: =>> :google.com:
What is the way to find in the txte pass.txt : 74.125.230.193:google.com:
Fawers wrote:The code he wrote is supposed to have both IP and domain name as parameters in order to echo them both.foxidrive wrote:Code: Select all
if %errorlevel%==0 >>pass.txt echo %1:%2&echo pass
if %errorlevel%==1 >>fail.txt echo %1:%2&echo FAIL
%1 and %2 are CL parameters.
CL Parameters = command line parameters.
If you already have the IP list along with their respective domain names, you just have to run foxi's code with them.
Re: Une boucle avec la command PING
alid0381,
Your request was poorly worded - I think what you want to do is to ping a set of domains and get the IP address and put them both in a text file like the following:
Is that right?
Try this:
domainlist.txt contains
google.com:
telstra.com:
Your request was poorly worded - I think what you want to do is to ping a set of domains and get the IP address and put them both in a text file like the following:
Is that right?
Exemple
193.52.104.60:forum.ubuntu-fr.org:
74.125.230.196:google.com:
Try this:
domainlist.txt contains
google.com:
telstra.com:
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f "delims=:" %%a in (domainlist.txt) do (
echo testing %%a
set domain=%%a:
for /f "tokens=2 delims=[]" %%b in ('ping -n 1 %%a ^|find "["') do set domain=%%b:!domain!
>>"IP.txt" echo !domain!
)
Re: Une boucle avec la command PING
How much you are wonderful and all the team
This is exactly what I want
Thank you Thank you Thank you...
This is exactly what I want
Thank you Thank you Thank you...