【问题标题】:Batch Error: “< was not expected at this time”批处理错误:“此时不应出现<”
【发布时间】:2019-04-02 23:54:29
【问题描述】:

我想使用 Ptexport 从 http 服务器获取信息,但我无法输入正确的语法。

我尝试过不同类型的语法。

wget.exe --user=export_kpi --password=kpi123 -O Result3.txt http://XX.YYY.CCC.BB/export/Export?req='<Ptexport version="1.6.0"><Request><ResultReq egname="test_kpi" templRR1="kpi_lost">'**

我明白了

我应该在 .txt 上这样写:

cat Result3.txt |sed 's/></>\n</g'
<Ptexport version="1.6.0" >
<Response>
<RR cid="1459546492000" sid="33966" eod="0">
<RR1 direction="0" statTime="1552888534574" dmax="400" />
<RR1 direction="1" statTime="1552888534574" dmax="413" />
<RR1 direction="0" statTime="1552888594575" dmax="466" />
<RR1 direction="1" statTime="1552888594575" dmax="487" />
<RR1 direction="0" statTime="1552888654575" dmax="371" />
<RR1 direction="1" statTime="1552888654575" dmax="427" />
</RR>
<RR cid="1459546492000" sid="33968" eod="0">
..etc

【问题讨论】:

  • 无论是从您的标签还是从您的命令中,都无法清楚您使用的是什么环境。在 cmd.exe 中,字符 &lt;&gt;|&amp; 必须用插入符号 ^ 转义或用双引号括起来。 windows wget、cat、sed默认不可用。

标签: windows shell batch-file command


【解决方案1】:

不要在您的网址中添加文字 &lt;。请改用%3C

here for a list of escape codes in a URL

【讨论】:

  • 从我得到的结果开始:连接到 10.114.245.98:80... 已连接。 HTTP 请求已发送,等待响应... 401 Unauthorized
【解决方案2】:

将您的网址用双引号括起来,如下所示

wget.exe --user=export_kpi --password=kpi123 -O Result3.txt "http://XX.YYY.CCC.BB/export/Export?req='<Ptexport version=,\"1.6.0\"><Request><ResultReq egname=\"test_kpi\" templRR1=\"kpi_lost\">'**"



【讨论】:

  • 从我得到的结果开始:连接到 10.114.245.98:80... 已连接。 HTTP 请求已发送,等待响应... 401 Unauthorized
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-01-17
  • 2012-08-18
  • 1970-01-01
  • 2020-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多