Find the answer to your Linux question:
Results 1 to 2 of 2
I need a shell script which will change the hostname , I need the script to prompt for a name if the name is localhost.localdomain.I am a newcomer in scripting. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    1

    Shell script to change host name


    I need a shell script which will change the hostname , I need the script to prompt for a name if the name is localhost.localdomain.I am a newcomer in scripting. So please help

    Thanks in advance

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429
    Is this homework?
    Well I am not going to give you the script since helping with homework is not allowed on the forums.
    but I can advice you.
    There is a file were you can find the hostname.
    The System reads it for the hostname.
    If you write a script to extract that line out of the file. To show the current hostname and then change it.
    Its really easy. Id do this with Perl if Id were you.
    You'll need to read the file line by line. Till its the right string you are looking for

    Hope I helped you without betraying something
    New Users, please read this..
    Google first, then ask..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •