OPS435 Lecture 6 - Bash

From CDOT Wiki
Revision as of 13:41, 22 August 2017 by Andrew (talk | contribs) (Andrew moved page OPS435 Lecture 6 to OPS435 Lecture 6 - Bash)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Today we looked at funtictions in bash. TLDP has a nice tutorial.

In-class example:

#!/bin/bash

printServiceStatus()
{
  if status $1 2>/dev/null | grep 'start/running' > /dev/null
  then
    echo "The service is running"
  else
    echo "The service is not running"
  fi
}

echo -n "Please enter service name:"
read SERVICENAME

printServiceStatus $SERVICENAME