批处理文件-从ping命令获取IP [英] batch file - getting ip from ping command

查看:437
本文介绍了批处理文件-从ping命令获取IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个命令.

ping -n 1 piratelufi.com | find /i "reply from"

我想在ping响应中获取ip.我想到使用%var:〜0,10%,但我不知道如何将输出重定向到echo.

i want to get the ip inside the ping response. i thought of using %var:~0,10% but i have no idea how to redirect the output to echo.

我什至尝试使用管道

ping -n 1 piratelufi.com | find /i "reply from" | echo %1 

,但是%1变量不代表前两个命令的输出.我什至尝试使用& 1,但我失败了.回显前两个命令的输出所需的变量"是什么?

but the %1 variable does not represent the output of the first two commands. i even tried to use &1 but i failed. What is the 'variable' needed to echo out the output from the first two commands?

推荐答案

查看FOR命令,它真的很酷:

Check out the FOR command it's really cool:

FOR /f "tokens=1,3 delims=: " %%A IN ('ping -n 1 piratelufi.com') DO IF %%A==Reply ECHO IP IS %%B

这篇关于批处理文件-从ping命令获取IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆