Bash script to monitor Webserver php script
#!/bin/bash


Minor, still good to know, this is not portable, f.e. BSDs will choke on it. This might not be an issue if you only intent to use it on Linux, but if you ever release script into the wild, you should consider using a portable shebang line.

#!/usr/bin/env bash




if [[ -z "$1" ]] # check if script arguement exists
then


I'm a friend of the one-line-style, but that is for sure a pure personal preference.

if [[ -z "$1" ]]; then # check if script arguement exists




a=$(./IDscript "server");


From the context of this I can say two things:


that variable needs a better name
that script needs a better name


It is not obvious what the script does and neither what the variable will hold.



a=$(./IDscript "server");


In a shell script, there's no need to close every line with a semicolon. You can do it, but it's not necessary.



lenA=$(expr length "$a");


If you're going to use Bash, you can also use Bash syntax:

lenA=${#a}


Or shortened to:

if [ ${#a} -eq 0 ] #check length of A is empty
then




if [[ -z "$1" ]]


What I made a habit out of in the last time is extracting arguments into named variables so that the script is easier to read.

webAddress=$1

if [[ -z "$webAddress" ]]
...
testURL=$webAddress"/checkError?which=IDError&amp;rand="$r;


This is of course not always useful, but pretty neat if you're going to use $1 in multiple places, as the script becomes easier to read.



echo -e "\n"; 


This can be shortened.

echo