5

The BSD version of Ping(8), notably on OS X, includes a convenient "one ping only" option (-o) that mirrors Sean Connery's famous quote from Hunt for Red October. The option terminates Ping once the first reply is received.

I am trying to find out when the option was added or dropped from Ubuntu's Ping implementation. A note on Ars Technica's forum seems to hint that this is an older option (and perhaps has now been dropped?).

Any historical insight would be useful.

Why is this handy? Because you can do stuff like this:

ping -o 1.2.3.4; ssh ubuntu@1.2.3.4 

and it will connect you with the server as soon as it becomes available on the network.

0xF2
  • 3,144
  • 4
  • 30
  • 55
  • You should ask the developer why a parameter was dropped. Also you can do a feature request to have `-o` option added back in. – WinEunuuchs2Unix Jun 01 '18 at 02:31
  • 7
    If you're looking for BSD history, the appropriate site would be [unix.se]. – muru Jun 01 '18 at 02:31
  • 3
    @Rinzwind the difference with `-o` is that `-o` pings until you get one reply, and `-c 1` pings exactly once, no matter the reply. – muru Jun 01 '18 at 07:58
  • 1
    @muru AFAIU the question was "When was this dropped in Ubuntu" and I seem to have uncovered the truth... Voting to reopen! **;-)** – Fabby Jun 07 '18 at 22:16
  • @Fabby well, even the 2005 Ars Technica forum post they link to gives no indication it's about Ubuntu, so for all I know they may be asking when was this dropped BSD ping (the Apple manpages available online are all for some legacy version). – muru Jun 07 '18 at 23:46
  • @DavidFoerster the question is: When was the `-o` dropped from the ping utility in Ubuntu and the answer is: it never existed in Ubuntu. (see answer) – Fabby Jun 08 '18 at 09:23
  • @DavidFoerster I'm an old fart: I'm used to reading in-between the lines. **;-)** (Which is also a disadvantage as I sometimes read too much in-between the lines and come to conclusions that make no sense sometimes) – Fabby Jun 09 '18 at 20:51
  • 1
    **0xF2** thanks for the upvote and acceptance. Favour returned: question upvoted! P.S. Please let me know what the Vasiliy reference is??? – Fabby Jun 09 '18 at 20:51
  • @fabby: there is a link to a youtube video in the question. "One ping only" https://www.youtube.com/watch?v=jr0JaXfKj68 – 0xF2 Jun 20 '18 at 18:59
  • 1
    :D Thanks. Saw that movie, but only once! – Fabby Jun 20 '18 at 20:41

1 Answers1

7

Today:

Use:

until ssh ubuntu@1.2.3.4 ; do sleep 0.25; done

to ssh into the server the moment it becomes available.

The past:

The earliest source code of the GNU inetutils I could find that contained ping is:

2001-06-13  Sergey Poznyakoff
    * ping.c: implemented
    * ping_address.c, ping_echo.c, ping_impl.h, ping_router.c,
      ping_timestamp.c: added to repository.

and that did not contain the -o parameter... So we can safely conclude that this option did not exist in 2001 and as Warty Warthog was released in 2004 we can prove beyond any doubt that this option never existed in Ubuntu.

;-)

Fabby
  • 34,341
  • 38
  • 97
  • 191
  • So to emulate the effect of `-o` as of [muru’s comment](https://askubuntu.com/questions/1042493/one-single-ping-vasily/1044588?noredirect=1#comment1698838_1042493), something like `until ping -c1 8.8.8.8 >/dev/null;do :;done`? – dessert Jun 07 '18 at 22:04
  • 1
    Edited... @dessert Vote to reopen then! – Fabby Jun 07 '18 at 22:15
  • Sounds like the -o option was never added to the GNU implementation... thanks for all the research! – 0xF2 Jun 09 '18 at 19:50
  • Turns out that to wait for ssh to come up there is actually a simpler solution: `until ssh ubuntu@8.8.8.8 ; do sleep 1; done` – 0xF2 Jun 09 '18 at 19:54
  • @0xF2: Thanks! Updating answer... FYI: Sleep accepts a floating point, so setting it to 0.25 checks every 250 ms. – Fabby Jun 09 '18 at 20:46
  • 1
    Why ssh into Google DNS server ? O.o Someone could really misunderstand that – Sergiy Kolodyazhnyy Jun 09 '18 at 21:33
  • I'll change it to 1.2.3.4 @SergiyKolodyazhnyy – Fabby Jun 10 '18 at 00:25