Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-14-2004, 10:21 AM   #1
LQ Newbie
Registered: Aug 2003
Posts: 19

Rep: Reputation: 0
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
Old 06-14-2004, 10:26 AM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
What type of script is it? Perl, csh, bash...
Old 06-14-2004, 10:28 AM   #3
LQ Newbie
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
It's a bash script running on suse linux...Thanks.
Old 06-14-2004, 10:34 AM   #4
Registered: May 2004
Location: Merida (Spain)
Distribution: Debian
Posts: 89

Rep: Reputation: 15
Hi anjaan:

in your script, try:


Old 06-14-2004, 10:39 AM   #5
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
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.
Old 06-14-2004, 10:41 AM   #6
LQ Newbie
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
`hostname` seems to be working.

Thanks all


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a shell script remotely via 'ssh <hostname> <command>' davee Linux - General 4 10-09-2005 01:38 AM
Append the windows path with Samba login script ?? amitsharma_26 Linux - Networking 2 09-29-2005 10:46 AM
Is it possible to script changes of hostname/ip on Suse 9.2 ES? merixon SUSE / openSUSE 0 04-18-2005 04:23 AM
How to append today's date in a script anjaan Programming 4 06-12-2004 08:37 AM
hostname command vs. $HOSTNAME env. variable Silly22 Linux - Networking 2 03-29-2002 05:01 PM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration