c++ - Save the IP of a domain to a txt file/Save my dynamic ip to a txt file with c++ 或批处理

标签 c++ networking batch-file ip hosts

^^^^

我需要将我的域 (xxx.noip.com) 或外部 IP 的 IP 保存到一个文本文件中。然后它将上传到公共(public)保管箱帐户。

最佳答案

您可以通过浏览到 http://checkip.dyndns.org 来获取您的外部 IP

假设您的 DropBox 文件夹是 C:\dropbox

这是一个批处理脚本,可将您的公共(public) ip 保存到 dropbox 文件夹中的文件中。

get_my_public_ip.bat:

wget -q -O - http://checkip.dyndns.org > C:\dropbox\my_public_ip.html

您将需要 wget为了让它运行,它应该放在你的 PATH 中的文件夹中。变量(例如 C:\Windows)。你可以找到一个windows端口here . HTML 标记不会从文件中删除,因此其内容类似于:

<html><head><title>Current IP Check</title></head><body>Current IP Address: 1.2.3.4</body></html>

这是一个 Windows PowerShell 脚本,它执行相同的工作并删除不必要的文本。

get_my_public_ip.ps1:

(new-object System.Net.WebClient).DownloadString('http://checkip.dyndns.org')|% { $_ -replace '.*Current IP Address: ([0-9\.]+).*','$1' } > C:\dropbox\my_public_ip.txt

检查 here获取有关如何运行 Windows PowerShell 脚本的一些帮助。

希望对你有帮助

关于c++ - Save the IP of a domain to a txt file/Save my dynamic ip to a txt file with c++ 或批处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14009118/

相关文章:

c++ - 什么时候虚拟继承是一个好的设计?

C++ 使用参数的默认值

c# - 如何在不使 header 信息无效的情况下通过网络传输发送对象

windows - 如何隐藏批处理输出

windows - 获取 Windows 批处理文件中的最后一个命令行参数

c++ - 背景扣除

c - 选择功能行为 - 多客户端测验

windows - 如何以编程方式找出哪台计算机是 Windows 中的域 Controller ?

windows - wmic 命令的批处理脚本中的文本乱码

c++ - 在 lambda 中包装并执行 packaged_task