|
Answer» I'm making a batch script to test on mail relay and it all works LIKE a charm, but to make it way easier to add or delete servers from the list that have to be checked I WANT my batch script to extract the IP from a txt file.
than you'll get something like this situation: script.BAT :LABEL A ping :GOTO A there needs to be a line that if he has pinged the ip, he deletes it from the list
ip.txt 10.2.3.4 133.71.33.7
anyone has any idea on how to do this?This should do the job:
find /v "ip_from_txt" ip_new.txt && del ip.txt && rename ipnew.txt ip.txt
uli
well, it almost works the part that works: he deletes the first ip the part that doesn't work: he doesn't "input" the command behind ping. i've allready tried making a file called "find.bat" that only had the "find /v etc etc" line in it and than run the "ping.bat" file with "ping | find.bat" or "ping < find.bat" in it.
any idea how to solve this?Hope I understand your problem right. This Loop will extract the ips from ip.txt, pings this ip and deletes the pinged ip from the list. It should work if your list is in dir c:\ The list has only ip adresses and nothing else. It finds every line with a point and takes the whole line. But deleting the pinged line doesn`t make sense cause ping gives always errorlevel 0 back, if the machine you pinged is working, or not. I would ping the machines and write the output in a log.txt. There you can check the output. (With a batchfile...)
@ECHO off For /f "skip=2" %%a in ('find "." c:\ip.txt') do (
ping %%a find /v "%%a" ip_new.txt && del ip.txt && rename ipnew.txt ip.txt )
:eof
ulitnx for your help but i allready solved it on another way i made a second batch script that saved the IP's as a variable (or how you type that :/), and than in the main batch script "ping $ip_1 ping $ip_2 etc"
but again, tnx for your help
|