小编Mos*_*362的帖子

批处理 - 有没有办法批量同步锁定txt文件?

我需要创建一个批处理文件,使用tracert命令跟踪一些ip,并将跟踪写入txt文件.我希望它快,所以我想为每个跟踪启动一个新命令,使所有跟踪请求立即启动.

有我的ping.bat:

@echo off
set saveUnrechableLocation=..\pingUnreachableInfo\pingUnrechableInfoDB.txt
set IpListLocation=..\ipInfo\all_DB_ip.txt
set reachableLocation=..\pingRechableInfo\RechableIp\pingRechableInfoDB.txt
set trace=..\pingRechableInfo\tracert\tracertDB.txt
set numberOfPings=1
@echo pinging DB > %saveUnrechableLocation%
copy /y NUL %reachableLocation% > NUL
copy /y NUL %trace% > NUL
for /F "tokens=*" %%A in (%IpListLocation%) do (
    ping -n %numberOfPings% %%A | find "TTL=" >nul 
    if errorlevel %numberOfPings% (
        @echo %%A not rechable >> %saveUnrechableLocation%
    ) 
    if not errorlevel %numberOfPings% (
    @echo %%A >> %reachableLocation%
    start trace.bat %trace% %%A
    )
)
Run Code Online (Sandbox Code Playgroud)

和trace.bat看起来像这样:

@echo off
set saveLocation=%~1
set ip=%~2 …
Run Code Online (Sandbox Code Playgroud)

text synchronization cmd file batch-file

5
推荐指数
1
解决办法
143
查看次数

标签 统计

batch-file ×1

cmd ×1

file ×1

synchronization ×1

text ×1