求助:代码实现不了效果,编程实在不会
1、文本文件List.txt内容如下:
220.181.108.184
220.181.108.183
220.181.108.182
220.181.108.181
2、上面域名在cmd下nslookup后的结果如下:
C:\>nslookup 220.181.108.184
服务器: xd-cache-1.bjtelecom.net
Address: 219.141.136.10
非权威应答:
名称: baiduspider-220-181-108-184.crawl.baidu.com
Addresses: 220.181.108.184
我要输出的格式:
ip:220.181.108.184,名称:baiduspider-220-181-108-184.crawl.baidu.com
ip:220.181.108.183,名称:baiduspider-220-181-108-184.crawl.baidu.com
ip:220.181.108.182,名称:baiduspider-220-181-108-184.crawl.baidu.com
ip:220.181.108.181,名称:baiduspider-220-181-108-184.crawl.baidu.com
我参考的帖子:http://www.bathome.net/thread-42102-1-1.html,中pcl_test,4楼的代码。请大神帮忙调整下,并输出TXT文档形式。- @echo off
- for /f %%a in ('more +22 "%~f0"') do (
- setlocal enabledelayedexpansion
- for /f "delims=" %%b in ('nslookup %%a 2^>^&1') do (
- for /f "tokens=1,2" %%c in ("#%%b") do (
- if /i "%%c" equ "#Address:" (
- set /p=DNSDZ:%%d YM:%%a<nul
- set s=%%dfedcba9876543210&set/an=0x!s:~15,1!
- for /l %%i in (1 1 !n!) do set "space=!space! "
- ) else (
- if not defined f (
- if /i "%%c" equ "#Addresses:" (
- echo; YMDZ:%%d
- set f=1
- )
- ) else if "%%c" equ "#" echo; !space!YM:%%a YMDZ:%%d
- )
- )
- )
- endlocal&echo;
- )
- pause&exit
- 220.181.108.184
- 220.181.108.183
- 220.181.108.182
- 220.181.108.181
复制代码
|