#!/bin/sh
# Tcl sees the next lines as an assignment to variable `kludge'.
# For sh, the two shifts cancel the effect of the set, and then we
# run scotty on this script.

set kludge { $*
    shift
    shift
    if test -f ../scotty ; then
      exec ../scotty -nf $0 $*
    else
      exec scotty -nf $0 $*
    fi
}

##
## Simply probe all RPC services on a given host
##

proc probe {host} {
    if {[catch {
	foreach s [sunrpc info $host] {
	    if {[catch {eval "sunrpc probe $host $s"} p]} {
		puts stdout "$host: $s\t(probe failed)"
	    } else {
		puts stdout "$host: $s\t$p"
	    }
	}
    } err]} {
	puts stderr $err
    }
}

if {$argc<1} {
    puts stderr "usage: rpcprobe hosts"
    exit
}

foreach name $argv {
    probe $name
}

exit
