我想创建一个.bat文件,它将执行for循环,如下所示:
@echo off
FOR /L %%G IN (1, 1, 69) DO (
ping -n 1 192.168.%%G.3
ping -n 1 192.168.%%G.4
)
Run Code Online (Sandbox Code Playgroud)
然后查看输出并仅将成功回复ping的IP发送到txt文件.这是否可以使用CMD批处理文件?
我有这个批处理文件,登录到远程机器上的sql运行存储过程,然后将输出发送到文本文件.我希望它将IP地址中的第3个八位字节和输出文本文件的名称递增1并循环,这样我就不必一遍又一遍地重复命令.此外,我希望它达到一定数量时停止.有没有办法做到这一点?
sqlcmd -U user -P password -S 192.168.1.2 -i c:\sql\storecreditfix.sql -o c:\sql\ouput01.txt
sqlcmd -U user -P password -S 192.168.2.2 -i c:\sql\storecreditfix.sql -o c:\sql\ouput02.txt
sqlcmd -U user -P password -S 192.168.3.2 -i c:\sql\storecreditfix.sql -o c:\sql\ouput03.txt
sqlcmd -U user -P password -S 192.168.4.2 -i c:\sql\storecreditfix.sql -o c:\sql\ouput04.txt
sqlcmd -U user -P password -S 192.168.5.2 -i c:\sql\storecreditfix.sql -o c:\sql\ouput05.txt
Run Code Online (Sandbox Code Playgroud)