test for name of localhost in script
I want to write a script that tests during execution on which machine it is running. I'd like to test for the name of the localhost, something like
Code:
if [ $localhost = fs01phy ]; then echo jepp ; fi Thanks, Lotharster |
there's always hostname or uname -a
localhost=`hostname` if test $localhost = whatever then something else something fi |
Try hostname -f for fully qualified domain or hostname -s for just the hostname cut off at the first dot. You can assign it a variable in your script if you want, i.e. LOCALHOST=`hostname -s`. Note that those are back quotes (the ~ key)
|
thanks for your quick replies!
Lotharster |
All times are GMT -5. The time now is 04:24 PM. |