#!/bin/sh  
# \
exec oagtclsh "$0" "$@"

set auto_path [linsert $auto_path 0  /usr/local/oag/apps/lib/$env(HOST_ARCH)]
set auto_path [linsert $auto_path 0 /usr/local/oag/lib_patch/$env(HOST_ARCH)]
APSStandardSetup

set usage {usage: makeMachineFile -output <filename>}
set output ""
set args $argv
if {[APSStrictParseArguments {output}] || ![string length $output]} {
    return -code error "$usage"
}
if [file exists $output] {
    return -code error "in use: $output"
}

if [catch {exec qstat -f | fgrep all.q | fgrep -v " adu" | fgrep -v " au" \
               | fgrep -v " d" | token -n=1 \
	       | editstring -stream -edit=%/all.q@// | fgrep weed} queueList] {
    return -code error "$queueList"
}
set fd [open $output w]
foreach item $queueList {
    catch {exec ping -c 1 -i 1 $item} result
    if [string match *error* $result]==0 {
	puts $fd "$item\n$item"
    }
}
close $fd
 
