[X-Unix] Bash scripting Question

Russell McGaha RussellMcGaha at hughes.net
Wed Aug 23 07:29:45 PDT 2006


Replying to David, Lasse, Stroller, and others;
	Guys [and/or Gals], THANKS for the tips and assistance.  With your  
help, I've got a working version; which I'll paste at the bottom of  
this message. Some of you had some questions which I'll try to answer:

	'fmsadmin list clients' does return an empty string if no clients  
are connected
		Yes this is part of FileMaker Server 7
	'fmsadmin' does not SEEM to return proper exit codes

The following code may be copied/used:
	if in it's entirety; if proper attribution is given
	if partially/modified: freely

Explanation:
	It sends a message to all connected clients that it's going to shut  
the server down, then waits for either; all clients to disconnect or  
3 minutes, giving an additional warning at 2 minutes, and then CLOSES  
all databases.
	A companion script re-opens the databases after I've finished  
updating the databases via rsync from a remote location.

#! /bin/sh

declare -i Csec Dsec Warning Tstart; Warning=0; Tstart=$SECONDS; Csec= 
$SECONDS; Dsec=Csec-Tstart;

fmsadmin -m"Im going to shutdown FileMaker Server 7; please quit  
FileMaker 7. " Send

Result=`fmsadmin list clients`

while [ "$Result" != "" ] && [ $Dsec -lt 180 ]
	do
	Result=`fmsadmin list clients`	#echo's are for diagnostics
	echo "/"$Result"/"				#Warning= if 2nd warning has been given
	sleep 10;					#Tstart = Time started  Csec= Current seconds   Dsec=  
Difference in the two
	Csec=$SECONDS; Dsec=Csec-Tstart; echo "Csec="$Csec "Dsec="$Dsec  
"Tstart="$Tstart;
	    if [ $Dsec -gt 120 ] && [ $Warning -ne 1 ]; then
		fmsadmin -m"Im going to shutdown FileMaker Server 7; please quit  
FileMaker 7.  LAST WARNING!!" Send
		Warning=1
		echo "re-sending warning"
		fi
	done

  fmsadmin -y Close

exit


More information about the X-Unix mailing list