呼叫URL用wget并返回根据URL的内容的ERRORLEVEL [英] Call URL with wget and return an ERRORLEVEL depending on URL's contents

查看:231
本文介绍了呼叫URL用wget并返回根据URL的内容的ERRORLEVEL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个客户端有一个基于Windows的内部服务器,其所编辑CMS的内容。的数据与实时Web服务器夜间同步。这是一个缓慢的互联网连接的解决方法。

A client has a Windows based in-house server, on which they edit the contents of a CMS. The data are synchronized nightly with the live web server. This is a workaround for a slow Internet connection.

有两件事情要同步:新建文件(已排序)和MySQL数据库。要做到这一点,我写的导出到数据库的转储文件使用 mysqldump的,并上载转储的脚本。

There are two things to be synchronized: New files (already sorted) and a mySQL database. To do this, I am writing a script that exports the database into a dump file using mysqldump, and uploads the dump.

上载过程中使用名为 ScriptFTP ,一个FTP自动化工具第三方工具来完成。

The upload process is done using a 3rd party tool named ScriptFTP, an FTP automation tool.

然后我需要运行在目标服务器上的基于PHP的导入脚本。根据这个脚本的返回值,则ScriptFTP操作的推移,以及一些目录改名。

I then need to run a PHP based import script on the target server. Depending on this script's return value, the ScriptFTP operation goes on, and some directories are renamed.

我需要为这个外部工具,如scriptFTP只支持FTP调用。我在想的Windows版本的的wget

I need an external tool for this, as scriptFTP only supports FTP calls. I was thinking about the Windows version of wget.

在scriptFTP,我可以执行任何批处理或exe文件,但我只能解析的错误级别从通话中产生的,而不是标准输出输出。这意味着,我需要返回 ERRORLEVEL 1 如果PHP导入操作出错,而错误级别0 如果一切顺利。此外,很明显,我需要返回如果要导入脚本的连接可能根本不会被作出了积极的ERRORLEVEL。

Within scriptFTP, I can execute any batch or exe file, but I can only parse the errorlevel resulting from the call and not the stdout output. This means that I need to return errorlevel 1 if the PHP import operation goes wrong, and errorlevel 0 if it goes well. Additionally, obviously, I need to return a positive errorlevel if the connection to the import script could not be made at all.

我有超过进口PHP脚本总量控制,并且可以决定它的错误呢:输出错误信息,返回头,无论

I have total control over the importing PHP script, and can decide what it does on error: Output an error message, return a header, whatever.

你会如何运行的wget(或任何其他工具揭开序幕服务器端导入),并根据不同的PHP脚本返回返回什么一定的误差水平?

我最好的选择,现在正在建设一个执行wget命令,将结果存储在一个文件中的批处理文件,批处理文件取决于文件的内容返回错误级别0或1。但我真的不知道如何使用批处理编程匹配文件的内容。

My best bet right now is building a batch file that executes the wget command, stores the result in a file, and the batch file returning errorlevel 0 or 1 depending on the file's contents. But I don't really know how to match a file's contents using batch programming.

推荐答案

您可以做在PowerShell中的以下内容:

You can do the following in powershell:

$a = wget --quiet -O - www.google.com
$rc = $a.CompareTo("Your magic string")
exit $rc

这篇关于呼叫URL用wget并返回根据URL的内容的ERRORLEVEL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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