【问题标题】:Batch file to count number of hops and run FTP based on the results批处理文件来计算跳数并根据结果运行 FTP
【发布时间】:2015-12-07 13:27:32
【问题描述】:

我需要创建一个批处理作业 (.bat) 文件来运行 FTP 复制到我的服务器,但是只有当服务器可以通过“tracert”(或任何其他命令)通过 1 跳到达时才能运行以防止作业当用户从远程位置登录 VPN 时停止运行。

我可以运行跟踪,但我不确定如何使用结果来限制 FTP 部分在跳跃不止一次时运行。

【问题讨论】:

    标签: batch-file ftp


    【解决方案1】:

    你可以试试这个:

    @echo off
    setlocal enabledelayedExpansion
    set hops=0
    FOR /F "tokens=1,8,9 delims= " %%A IN ('Tracert -h 2 127.0.0.1') do (
    set /a test=%%A*1
    if !test! geq 1 set /a hops=!hops!+1
    )
    if %hops% lss 2 echo run ftp-command here
    

    这会检查所需的跳数是否为 1,如果为真则执行命令。 您仍然需要将 127.0.0.1 更改为您的 IP,并将您的命令放在 echo 所在的位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-30
      • 2013-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多