Hostnames as Bash Commands

Uri Guttman uri at
Fri Jan 4 19:41:33 GMT 2008

>>>>> "S" == Smylers  <Smylers at> writes:

  S> There are lots of ways of doing things like this.  I wasn't suggested
  S> that what I came up with was the best behaviour for anybody else, nor
  S> that it's the only (or even best) way of implementing that behaviour.

  >> (.bash_profile):
  >> # 1 hostname per line
  >> HOSTFILE=~/.hosts

  S> That involves manually updating a list of hosts that I might want to SSH
  S> to; mine and Bob's configurations automatically pick that up from
  S> previous SSH activity.

i dunno if this will directly work with ssh now but it would be trivial
to write a short bash script to handle it. in days of yore in olde SUNOS
days (the bsd flavor) when rsh was in vogue, there was a simple way to
add hosts as auto rsh commands. sun even provided a script to do it for
you from the hosts file. it would make symlinks (or hardlinks should
work too) in a dir with the host names linked to the rsh binary. rsh was
smart enough to notice a different command name and use that for its
host target. you had to put the dir in your path and it worked
great. the same thing could be done in a couple of lines (or 1 line i
bet - something like ssh $0) in bash. just link all the host names in a
dir to this script. sounds easier than most of the other
solutions. adding a new host is easy or trivially generated from various
sources. no need for fancy shell support (this will work with any
shell). also the hosts dir can be shared by all users and even over the
local net.

just my ancient $.02,


Uri Guttman  ------  uri at  --------
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------

More information about the mailing list