Changes

Jump to: navigation, search

OPS435 Lecture 6 - Bash

328 bytes added, 01:04, 11 March 2016
no edit summary
Today we looked at funtictions in bash. TLDP has a [http://tldp.org/LDP/abs/html/functions.html nice tutorial].
 
In-class example:
 
<source lang="bash">#!/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</source>

Navigation menu