[X-Unix] Bash scripting help

Philip J Robar pjrobar at areyoureallythatstupid.org
Tue Nov 8 09:56:18 PST 2005


On Nov 8, 2005, at 8:02 AM, Russell McGaha wrote:

> I'm trying to check if a process is running before continuing my  
> script
> (BTW I'm a relative new-be at shell scripting); here's what I've  
> tried:

http://www.shelldorado.com

and

Advanced Bash-Scripting Guide by Medel Cooper at <http://www.tldp.org/ 
LDP/abs/html/>

are good places to look for shell scripting help.

Here's my version of your script.

Phil


#!/bin/bash

FileMaker="";
let loop=0;													# Could also be ((loop = 0)), or let "loop = 0"

echo "Start"

# "[[" is an extended form of test. It lets "&&" behave as you  
expected it to.
# '<' seems like it should have worked since it's within double  
parentheses,
# but "-lt" definitely gives the expected numerical result.

while [[ "$Filemaker" == "" && ((loop -lt 10)) ]]; do		# "$loop"  
within double parentheses is incorrect.

	# Command Substitution, "$(some command)" - replaces "$(some  
command)" with output of the command.
	# Normally one would use some form of ps(1) in this situation.
	# foo(someNumber) refers to the "foo" command in section  
"someNumber" of the man pages.

	Filemaker=$(top -l1 | grep "FileMaker")
	echo "Filemaker = " $Filemaker

	let loop++												# Could also be ((loop++))
	echo $loop

done

echo "stopping"

exit 0



More information about the X-Unix mailing list