LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-29-2007, 11:57 AM   #1
Mangled
LQ Newbie
 
Registered: Jun 2007
Posts: 13

Rep: Reputation: 0
updating/re-writting the /etc/hosts file


Hi all

I have a problem, I need to read the hosts file for a string, and if the IP address for the name is incorrect i need to update the IP address and update it with the correct one then write it to the file

I have a script that sends the correct IP to the servers as a file, the problem is that I need to know how to update the hosts file with the new IP, I figured out how to read the file and store it in a field, but thats about it

The biggest thing is that I dont know much about bash, with the exception of basic functions, if you could point me in the right direction would help a lot

Thanks
 
Old 10-29-2007, 12:12 PM   #2
apolinsky
Member
 
Registered: Oct 2004
Location: Brooklyn
Distribution: Slackware 15;
Posts: 440

Rep: Reputation: 46
/etc/hosts is a text file. Any text editor can read it. You will need to be signed in as root in order to write changes. Though I use vi or vim for text editing, you could use emacs (rather large and somewhat complicated) ee (enhanced editor)to do the editing.
 
  


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
Reading text file-writting binary file cdog Programming 5 06-13-2006 11:56 AM
writting to file in php blitzX Programming 2 01-16-2005 02:57 PM
Is a file in writting ? stephnane AIX 3 08-02-2004 11:17 PM
Is a file in writting stephnane Linux - General 2 07-30-2004 09:39 PM
automatically updating the hosts file sal_paradise42 Linux - Networking 3 12-31-2003 10:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:49 AM.

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