Tiny Core Linux

General TC => General TC Talk => Topic started by: remus on September 24, 2014, 09:51:09 PM

Title: scripting with hostname
Post by: remus on September 24, 2014, 09:51:09 PM
Hi all,

I'm writing a bash script to do a backup, and am wondering how I use the hostname in a bash script in tinycore.

If I type hostname enter from the prompt, I get the following.

Code: [Select]
$ hostname
backserver

However I have had no luck using it in my script. I just want to echo the hostname of the server running the script into a log file, that has some other stuff in it.

Any suggestions and comments welcome.

Thanks.
Title: Re: scripting with hostname
Post by: Rich on September 24, 2014, 10:33:04 PM
Hi remus
This will append the hostname to the end of filename.log:
Code: [Select]
hostname >> filename.log