# get hostname in script



## Beeblebrox (Mar 9, 2013)

I'm trying to complete a script and I cannot manage to find how to assign the machine hostname to a variable. The google is not much help either. The script goes something like:

```
: ${node='uname -n'}
: ${app_log_file="/var/log/app/${node}.log"}
```
This does not work and host name is not being stored in the $node variable. How can I do this?


----------



## Anonymous (Mar 9, 2013)

Replace the single quotes by back ticks *`*, and your example should work as is.


----------



## Beeblebrox (Mar 9, 2013)

Ah, yes back ticks. I don't have any of those, I bathe regularly. My dog may have some though...
It worked - thanks.


----------



## wblock@ (Mar 9, 2013)

hostname(1) makes the script clearer.


----------



## Beeblebrox (Mar 9, 2013)

I see why I failed: I had tried "echo $hostname"


----------

