LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to append hostname in a script (https://www.linuxquestions.org/questions/programming-9/how-to-append-hostname-in-a-script-193349/)

anjaan 06-14-2004 10:21 AM

How to append hostname in a script
 
Hi all,

I am running a script that outputs result.html. How do I append the hostname to the script so that the output will be hostname_result.html

Reason for doing this is I want to run this script on multiple serves.

Thanks in advance

crabboy 06-14-2004 10:26 AM

What type of script is it? Perl, csh, bash...

anjaan 06-14-2004 10:28 AM

It's a bash script running on suse linux...Thanks.

Goala 06-14-2004 10:34 AM

Hi anjaan:

in your script, try:

HOSTNAME=`hostname`
OUTPUTFILE=${HOSTNAME}_result.html

bye.

Hko 06-14-2004 10:39 AM

Quote:

HOSTNAME=`hostname`
When using bash, this line is not needed (bash sets HOSTNAME variable automatically).
It's harmless though, it just slows the script down a little.

anjaan 06-14-2004 10:41 AM

`hostname` seems to be working.

Thanks all


All times are GMT -5. The time now is 11:16 PM.