title: Port Scanner on with Bash
body: <pre><code>#!/bin/bash
  host=$1
  startport=$2
  stopport=$3
  
  function pingcheck
  {
    ping = `ping -c 1 $host | grep bytes | wc -l`
    if [ $ping &gt; 1 ]; then
      echo "$host is up";
    else
      echo "$host is down quitting";
      exit
    fi
  }
  
  function portcheck
  {
    for ((counter=$startport; counter&lt;=$stopport; counter++))
    do
      (echo &gt; /dev/tcp/$host/$counter) &gt; /dev/null 2&gt;&amp;1 &amp;&amp; echo "$counter open"
    done
  }
  
  pingcheck
  portcheck
  </code></pre>
  
  <p>I tried testing the script by passing 127.0.0.1 1 5 to it from the terminal but all i keep getting is ping: unknown host = 
  127.0.0.1 is down quitting. Tried with other IP Addresses as well, I got the same output. I was following instruction from a book as I am new to shell scripting. It will be helpful if someone can tell me what I am doing wrong.</p>