[NBLUG/talk] Shell scripts and stdout

David shadoweyez at hotpop.com
Thu Jan 13 16:56:33 PST 2005


For all you shell script wizards:

I'm making a shell script that will log into the machine on the network 
with the lowest load average, using rlogin, and I have a command string 
that tells the machine with the lowest load that rlogin will use to log 
in to: ruptime -lr | grep up | head -n 1 | awk '{ print $1 }' will print 
out the host name.

How do I pass this to the host parameter of rlogin?  This script uses 
the tcsh shell and I've tried to use
set UPHOST = ruptime -lr | grep up | head -n 1 | awk '{ print $1 }'
and then rlogin $UPHOST but to no success.

Redirecting and piping also do not work because the hostname is not a 
command or file.  How do I redirect the stdout (the output of the 
commands that would normally go to the screen) to a variable, UPHOST in 
a shell script?  Is this possible?  I've also tried setenv but to no avail.

TIA,
David





More information about the talk mailing list