[X-Unix] Bash scripting help
Russell McGaha
RussellMcGaha at direcway.com
Tue Nov 8 11:53:52 PST 2005
Philip;
THANKS for the mini tutorial; your info on command substitution
helped with the last problem I was having.
THANKS again;
Russell
On Nov 8, 2005, at 11:56 AM, Philip J Robar wrote:
>
> 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
>
> _______________________________________________
> X-Unix mailing list
> X-Unix at listserver.themacintoshguy.com
> http://listserver.themacintoshguy.com/mailman/listinfo/x-unix
>
> Listmom is trying to clean out his closets! Vintage Mac and random
> stuff:
> http://search.ebay.com/_W0QQsassZmacguy1984
More information about the X-Unix
mailing list