Mysql 在批处理脚本中调用URL并将输出保存到变量或文本文件?
我正在使用批处理文件检查mysql站点的状态。现在网站上的一切都很好,所以当我连接到它时,它会说类似于Mysql 在批处理脚本中调用URL并将输出保存到变量或文本文件?,mysql,batch-file,url,vbscript,Mysql,Batch File,Url,Vbscript,我正在使用批处理文件检查mysql站点的状态。现在网站上的一切都很好,所以当我连接到它时,它会说类似于用户在线或离线。需要一个批处理文件来调用url,并将页面输出保存到文本文件中。这篇文章没有保存输出就完成了我的要求:。只要可以通过批处理文件调用,它就可以是vbscript。非常感谢 上面帖子中的原创脚本: @if (@This==@IsBatch) @then @echo off rem **** batch zone *************************************
用户在线
或离线
。需要一个批处理文件来调用url,并将页面输出保存到文本文件中。这篇文章没有保存输出就完成了我的要求:。只要可以通过批处理文件调用,它就可以是vbscript。非常感谢
上面帖子中的原创脚本:
@if (@This==@IsBatch) @then
@echo off
rem **** batch zone *********************************************************
setlocal enableextensions disabledelayedexpansion
rem Batch file will delegate all the work to the script engine
if not "%~1"=="" (
wscript //E:JScript "%~dpnx0" %1
)
rem End of batch area. Ensure batch ends execution before reaching
rem javascript zone
exit /b
@end
// **** Javascript zone *****************************************************
// Instantiate the needed component to make url queries
var http = WScript.CreateObject('Msxml2.XMLHTTP.6.0');
// Retrieve the url parameter
var url = WScript.Arguments.Item(0)
// Make the request
http.open("GET", url, false);
http.send();
// All done. Exit
WScript.Quit(0);
如果您不介意使用批处理中的powershell:
:: WebResponse.cmd
@Echo off
For /f "delims=" %%A in (
'powershell -NonI -NoP -C "(Invoke-Webrequest "%~1").content"'
) Do Echo one line of Webresponse %%A
带有指向的URL的示例输出
通过a:
for/F“delims=“%%I in('wscript//E:JScript“%%~dpnx0”“%%~1”)do(回显一行输出:%%I)捕获wscript//E:JScript“%%~dpnx0”“%%~1”的输出。
我如何使用包含问号的url实现这一点?我正在调用此URL:http://Website.com/teststat.php?username=Lukaka
。它不断回复:Webresponse Invoke WebRequest的一行:找不到接受参数“Lukaka”的位置参数。
请引用URL。”http://Website.com/teststat.php?username=Lukaka“
或转义等号^=
(cmd在=
处拆分参数)好的,谢谢。我试试看。编辑:我试过了,效果很好!非常感谢,感谢您的快速回复!
> WebResponse.cmd "http://api.ipify.org"
one line of Webresponse 93.226.203.xxx