[Techtalk] bash: test for correct host

Almut Behrens almut-behrens at gmx.net
Sat Aug 28 15:47:44 EST 2004


On Sat, Aug 28, 2004 at 09:19:07AM -0400, aec wrote:
> 
> the one syntax part I cant figure out is to
> test for hostname.
> 
> 
> #!/bin/bash
> # test script
> 
> if [$HOSTNAME="desktop"];
> then
> 
>     echo "host ok"
> 
> else
>     
>     echo "host not ok"
> 
> fi    
> 
> This dosent work, with the error,
> bash: [desktop: command not found


try

  if [ "$HOSTNAME" = "desktop" ]

A few month back we had a rather long thread on a similar issue, so
without wanting to sound 'rtfm'-like, let me just point you there... :)

http://mailman.linuxchix.org/pipermail/programming/2004-April/001255.html

Cheers,
Almut



More information about the Techtalk mailing list