【问题标题】:How to open browser on windows with url which contains metacharacters如何使用包含元字符的 url 在 Windows 上打开浏览器
【发布时间】:2016-01-30 21:51:30
【问题描述】:

我尝试用不同的方式打开浏览器 像这样的

system('start ' . $url) 或使用特殊模块 Browser::Open 他打开了网址,但不是全部,只有 http://host.com/cgi-bin/nagios3/status.cgi?hostgroup=all

我忘了注意,我需要打开 http://host.com/cgi-bin/nagios3/status.cgi?hostgroup=all&style=detail&servicestatustypes=28&sorttype=2&sortoption=3

【问题讨论】:

  • Windows perl 或 cygwin perl? (perl -V:archname 是什么)
  • MSWin32-x64-多线程

标签: windows perl system metacharacters


【解决方案1】:

&对于shell有特殊意义,所以需要将URL放在引号中。

但是start 有一个非常不寻常的语法。如果第一个参数在引号中,则它被视为窗口的标题。所以你需要添加一个虚拟的第一个参数。解决方法如下:

system(qq{start "" "$url"})

【讨论】:

  • 是的,它在 cmd 中有效,但是在 perl 脚本中 $url 必须被插值,他试图打开 '$ulr' 而不是值。
  • 非常感谢,很有帮助,我怎么会忘记qq。
  • 您也可以像原来一样使用串联。
【解决方案2】:

根据system

use strict;
use warnings;

my $url ="http://host.com/cgi-bin/nagios3/status.cgi?hostgroup=all";
system('start', $url);

上面运行的代码截图:

【讨论】:

  • @DimaCandu 你确定吗?它有效,添加了屏幕截图。也许你必须解释什么是行不通的。
  • 我需要打开这个网址host.com/cgi-bin/nagios3/…
猜你喜欢
  • 2021-07-12
  • 1970-01-01
  • 1970-01-01
  • 2020-05-27
  • 1970-01-01
  • 2012-12-24
  • 1970-01-01
  • 2018-01-29
  • 2019-04-12
相关资源
最近更新 更多