[X-Unix] Bash scripting Question

Stroller macmonster at myrealbox.com
Tue Aug 22 20:44:15 PDT 2006


Hi there,

This doesn't really help with the stated desire to "go thru this loop  
until [either] the output of the command is null", although (if x is  
high enough) it might be used to comply with the "about 2-5 minutes  
have gone by" part.

I would do something like this:


   #!/bin/bash

   # user can change this variable
   timeout=300 # in seconds

   # initialise stuff
   test="initialised"
   start=`date +%s`

   let "end = $start + $timeout"

   until  [[ "$test" = "" || `date +%s` -ge "$end" ]] ;
   do
       test=`fmsadmin status Clients`
   done

   exit 0

This does, however, depend upon `fmsadmin status Clients` returning  
an empty string to stdout when no clients are connected, tho'. Since  
I can't find a manpage online for `fmsadmin` I don't know whether it  
does so or not.

Stroller.



On 22 Aug 2006, at 21:51, Lasse wrote:
> ...
> while variable x is not equal to zero, do whatever need doing,  
> increment/decrement variable x, done
>
> Or is it something else you're looking for?
>
> oh, and make sure to put a line in your while statement for  
> updating variable x,
> one normal  way would be like
>
>> while	[ $x -ne 0 ]; do
>> 			 fmsadmin status Clients
>> 				let "x = $x + 1"
>> 		done
>
> ...
>
>>>> 	fmsadmin status Clients   #[returns a list of connected  
>>>> clients; I'd like to got thru
>>>> 							  this loop until either the output of the command is  
>>>> null or
>>>> 							  About 2-5 minutes have gone by]#


		
___________________________________________________________ 
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal 
http://uk.docs.yahoo.com/nowyoucan.html


More information about the X-Unix mailing list