title: How to return the PID from a bash script executed from a bash script
body: <p>The get_pid() function below is intended to return the PID of <code>daemon_itinerary.sh</code>.  </p>
  
  <p>The script below is not in the same working directory as <code>daemon_itinerary.sh</code>.</p>
  
  <pre><code>#!/bin/bash
  
  PID=""
  
  get_pid() {
      PID='pidof daemon_itinerary.sh'
  }
  
  start() {
      echo "Restarting test_daemon"
      get_pid
      if [[ -z $PID ]]; then
          echo "starting test_daemon .."
          sh /var/www/bin/daemon_itinerary.sh &amp;
          get_pid
          echo "done. PID=$PID"
      else
          echo "test_deamon is alrady running, PID=$PID"
      fi
  }
  
  case "$1" in
  start)
      start
  ;;
  ...
  *)
      echo "Usage: $0 {start|stop|restart|status}"
  esac
  </code></pre>
  
  <p>*edit</p>
  
  <p>Start is being passed in as a command line argument.  </p>