Skip to content

Instantly share code, notes, and snippets.

@papiron
Last active September 10, 2017 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papiron/63f8817e4100c246d37737d1e5e24cbc to your computer and use it in GitHub Desktop.
Save papiron/63f8817e4100c246d37737d1e5e24cbc to your computer and use it in GitHub Desktop.
pingで「にゃーん」をRubyで
元ネタ:
https://twitter.com/kooshin/status/900923276049891328
http://www.itmedia.co.jp/news/articles/1709/07/news106.html
シェル芸で再現版:
https://twitter.com/grethlen/status/906154326975905793
https://gist.github.com/greymd/79ebdeb31ea08538c76e546ae469ced6
https://twitter.com/ryuichiueda/status/906289652381786112
pingで「にゃーん」のやつ、Rubyでも再現してみたよ。Ciscoルータ持ってない人もこれでほっこり。シェル芸で再現してる人もいるよ。
Rubyの'net/ping'を利用。ICMPを送信するには管理者権限が必要なのでsudoしてます。
端末から下記ワンライナーを実行してみてください。時間がかかるのと途中停止がやりにくいのでご了承ください。
相手側サーバの負荷が気になるので、pingを投げる時間間隔を入れました。時間がかかりますが気長にお待ちください。
$ sudo ruby -r 'net/ping' -e 'p1 = Net::Ping::ICMP.new("pong.kooshin.net"); p1.timeout=0.1; (1..1400).each{|i| print p1.ping? ? "!" : "U"; print "\n" if i%70==0; sleep 0.1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment