MACSCRPT Archives

August 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Russell McGaha <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 23 Aug 2006 09:29:45 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (52 lines)
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

ATOM RSS1 RSS2