views:

603

answers:

3

How to ping a computer if the computer name starts with dash "-"

+12  A: 

On *nix, use a "--" to allow an argument beginning with a dash:

ping -- -funkyhost

(This probably won't help on Windows, though, because Windows command-line parsing is kind of rudimentary)

On another side note, well-formed DNS names are not allowed to start with a hyphen.

Andrew Medico
+1 for noting that valid RFC-compliant hostnames cannot start (or end) with a hyphen.
tvanfosson
Same with _underscore_, you can have it in a Windows computer name, but it's not an RFC-compliant host name, so I stay away from using it.
Bratch
+2  A: 

On Windows:

Try escaping out the dash with a backslash ('\') character:

ping \-<hostname>.<domain>
LeopardSkinPillBoxHat
A: 

What about using an IP address?

kruczkowski
What if you don't know the IP address, or if it is prone to change?
Joren