koldfront

Quick "host is up" #commandline #email #net

🕗︎ - 2016-06-12

Using ping(8) to determine whether a host on the local network is up is easy, but a bit slow - especially if what you are doing is checking whether it makes sense to ask the jukebox what song is playing, so you can add an X-Now-Playing: header to the email/article you are composing.

So I went hunting for someting quicker, and came up with this little script, using nmap(1):

  #!/bin/sh
  CHECK=$1
  nmap -PS --max-retries 1 --max-rtt-timeout 20ms --host-timeout 20ms $CHECK | grep --quiet 'Host is up'
  RET=$?
  if [ $RET = 0 ]; then
      echo "UP"
  else
      echo "DOWN"
  fi
  exit $RET

Works nicely.

Add comment

How to in excruciating detail…

To avoid spam many websites make you fill out a CAPTCHA, or log in via an account at a corporation such as Twitter, Facebook, Google or even Microsoft GitHub.

I have chosen to use a more old school method of spam prevention.

To post a comment here, you need to:

  • Configure a newsreader¹ to connect to the server koldfront.dk on port 1119 using nntps (nntp over TLS).
  • Open the newsgroup called lantern.koldfront and post a follow up to the article.
¹ Such as Thunderbird, Pan, slrn, tin or Gnus (part of Emacs).

Or, you can fill in this form:

+=