[NBLUG/talk] Shell scripts and stdout
Mitch Patenaude
mrp at sonic.net
Thu Jan 13 18:09:28 PST 2005
On Jan 13, 2005, at 4:56 PM, David wrote:
> 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.
Wow.. a couple of things to discuss here. First, rlogin is only
designed for interactive use. rsh is designed for automated tasks, but
both are such security holes that I think you'd be better off using
ssh, which was designed as a drop-in replacement for rsh. It will work
even if you are doing something interactive.
Second.. and this is what you really need to know... If you want the
output of that series of commands, you need to enclose them in
backquotes, like so:
set UPHOST=`ruptime -lr | ... | awk '{ print $1 }'`
You can even save a step by just doing the substitution directly on the
command line.
ssh `ruptime -lr | ... | awk '{ print $1 } '`
If you make the authentication automatic (try "man ssh-keygen"), then
this is a great way to automate things like distributed build
environments, etc.
-- Mitch
More information about the talk
mailing list