为什么-c选项不起作用? (ping选项)

时间:2017-04-28 14:04:23

标签: bash ping

我想做一件非常简单的事:ping一台机器。问题是我只想做一次。我做了一些研究,我发现-c选项正是我需要的。但由于我不明白的原因,我的终端无法识别它...它说“无效选项”,它怎么可能?

我在Windows 7 Enterprise计算机上使用Cygwin。

Screenshot of the error message.

2 个答案:

答案 0 :(得分:1)

看起来你正在使用Windows ping二进制文件,而不是linux。 http://www.computerhope.com/pinghlp.htm

考虑为Windows的二进制使用适当的选项(在我看来我认为是-n

答案 1 :(得分:1)

你可以用-n替换-c。 在 linux 中,您可以使用-c,但在Windows中并使用cygwin,您可以使用-n。 这是ping的男人页面

     -a     Audible ping.
     -A     Adaptive  ping.  Interpacket interval adapts to round-trip time,
          so that effectively not more than one (or more,  if  preload  is
          set)  unanswered probe is present in the network. Minimal inter‐
          val is 200msec for not super-user.  On  networks  with  low  rtt
          this mode is essentially equivalent to flood mode.

   -b     Allow pinging a broadcast address.

   -B     Do  not  allow  ping  to  change  source address of probes.  The
          address is bound to one selected when ping starts.

   -c count
          Stop after sending count  ECHO_REQUEST  packets.  With  deadline
          option, ping waits for count ECHO_REPLY packets, until the time‐
          out expires.

在linux -c count cygwin 中,该选项为 -n count