Script Shell Extracting hostname


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script Shell Extracting hostname
# 8  
Old 07-23-2015
host localhost
# 9  
Old 07-23-2015
Did you consider the hostname command?
# 10  
Old 07-23-2015
Hello All,

We should be little careful with command hostname as if by mistakenly(eg-> hostname NEW_NAME) we have given something like typo etc with it then it will set the hostname of the system to NEW_NAME(Which we had given as typo/unintentionally). This is active right away and will remain like that until the system will be rebooted (because at system boot it will set this from some particular file configurations). Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh. But off course we should be root for same.

Thanks,
R. Singh

Last edited by RavinderSingh13; 07-23-2015 at 02:14 PM..
This User Gave Thanks to RavinderSingh13 For This Post:
# 11  
Old 07-23-2015
Resolved with :
Code:
 hostname -f

# 12  
Old 07-23-2015
On some Unix OS the
Linux command hostname -f sets the hostname to -f!
I usually prefer host `uname -n` plus the just discussed filtering.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

2. Shell Programming and Scripting

Ping the hostname of many servers using a script

Hi We have some 300 servers in the Data center and some of them are running with AIX and some of them are running with Solaris. I need a script which can be run in one of the server and that script should ping the hostname of all the 300 servers. Also the script should notify if any server is... (9 Replies)
Discussion started by: newtoaixos
9 Replies

3. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

4. Shell Programming and Scripting

Extracting data from https server with the help of unix shell script

There is a folder which can be accessed through URL by giving a particular Username and Password.Inside the folder there are few excel sheets.The excel sheets/folder need to be imported from there to unix box with the help of unix shell script. Can anyone help me?Does anyone have code for it?... (2 Replies)
Discussion started by: vanur
2 Replies

5. Shell Programming and Scripting

extracting function headers in a c/c++ file using shell script

Hi, Is there any way to extract function headers from c and c++ files using a shell script? I tried to do it by reading the C/C++ file line by line and if a line matches a particular pattern (pattern of function header) i extracted it otherwise moved to next line. The problem here is, some... (3 Replies)
Discussion started by: priyadarshini
3 Replies

6. Shell Programming and Scripting

fetch hostname and instance name using shell script

Hi All, Requirement is to fetch hostname and instance name using shell script from all configuration files on a server R12 on IBM AIX... could anyone please share such an experience encountered before.Is there such a script available in this forum or any other site.. Thanks for your time!... (0 Replies)
Discussion started by: a1_win
0 Replies

7. Shell Programming and Scripting

shell script for extracting out the shortest substring from the given starting and en

hi all, i need an urgent help for writing a shell script which will extract out and print a substring which is the shortest substring from the given string where first and last character of that substring will be given by the user. for e.g. if str="abcdpqracdpqaserd" now if the user gives 'a'... (18 Replies)
Discussion started by: pankajd
18 Replies

8. Shell Programming and Scripting

urgent-extracting block data from flat file using shell script

Hi, I want to extract block of data from flat file. the data will be like this start of log One two three end of log i want all data between start of log to end of log i.e One two three to be copied to another file. This particular block may appear multiple times in same file. I... (4 Replies)
Discussion started by: shirish_cd
4 Replies

9. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies
Login or Register to Ask a Question