2018-10-21 22:26:32
此处为个人网志,请勿发表任何求档的评论或留言,一旦见到一定删除。本 Blog 域名为 www.ronnier.me,原域名
友情链接年代久了,整理了一下,虽然我已尽力做到最细致,但误伤也是难免的,还望见谅。
如有任何问题,请使用↖留言簿↖联络我。
站内文件如果下载到的是 .bin 文件请自行去除 .bin 扩展名。
获得域名解析结果的脚本
[ 2015-01-07 23:46:00 | 作者: Ronnier ]
在批处理或者 Shell 脚本中经常需要直接获取某域名解析结果的 IP 地址,可以用这样的方法,以下为带上域名作为参数的示例:
resolv.cmd
resolv.cmd
@if "%1" == "" goto :eof
@for /f "usebackq delims=[] tokens=2" %%n in (`ping -n 1 %1`) do @(echo %%n & goto :eof)
resolv.sh@for /f "usebackq delims=[] tokens=2" %%n in (`ping -n 1 %1`) do @(echo %%n & goto :eof)
#!/bin/sh
if [ ! "$1" ]; then exit 1; fi
ping -c 1 $1 | head -1 | cut -d')' -f1 | cut -d'(' -f2
具体用到各种脚本中通常直接将域名写到命令里面去的了,另外我用的是 ping,用 nslookup 也是 OK 的,就是 tail 和 for 的语句要稍微改改罢了~
if [ ! "$1" ]; then exit 1; fi
ping -c 1 $1 | head -1 | cut -d')' -f1 | cut -d'(' -f2
今天又把这网站开出来了
这次的服务器是偷偷架起来的
不保证能活多久……
这次的服务器是偷偷架起来的
不保证能活多久……
![[sweat]](styles/default/images/smilies/icon_sweat.gif)
1