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:
Philip Aker <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Tue, 22 Aug 2006 11:44:12 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (51 lines)
On 2006-08-22, at 09:11:06, Russell McGaha wrote:

> Folks;
> 	I've got a situation where I running a script and need to wait  
> till the output of a command is null:
>
> ex.
> 	NotNull = true
> 	While NotNull
> do
> 	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]#
> done

You should be able to adapt the following for your purposes.
The example runs for 18 seconds and pauses for 1 second in between  
'ping' calls.
The time required for the 'fmsadmin' call may actually need a larger  
pause
depending on network conditions

#!/bin/sh
# Copyright © 2003, Philip Aker <[log in to unmask] \
exec tclsh "$0" "$@"

set tstart [clock seconds];
set tend [expr $tstart + 18];

while {[expr [clock seconds] < $tend]} {
	#set result [exec fmsadmin status Clients];
	set result [exec ping -c 1 www.apple.com]
	if {[string length $result] > 0} {
		puts $result;
		set result ""
	} else {
		break;
	}
	after 1000;
	if {[clock seconds] == $tend} {
		break;
	}
}

puts "\n################# THE SCRIPT IS FINISHED #################"


Philip Aker
[log in to unmask]

ATOM RSS1 RSS2