LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 06-14-2004, 10:21 AM   #1
anjaan
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
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
What type of script is it? Perl, csh, bash...
 
Old 06-14-2004, 10:28 AM   #3
anjaan
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
Goala
Member
 
Registered: May 2004
Location: Merida (Spain)
Distribution: Debian
Posts: 89

Rep: Reputation: 15
Hi anjaan:

in your script, try:

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

bye.
 
Old 06-14-2004, 10:39 AM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

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

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

Thanks all
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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