Advertisement

07.08.2008 at 08:44PM PDT, ID: 23549024
[x]
Attachment Details

Script help

Asked by rdashokraj in Perl Programming Language, Bourne-Again Shell (bash), Shell Scripting

Hello,

Below given is a sample /etc/hosts file, where "cache01h-t1" is the hostname of a linux machine.

# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#::1            localhost6.localdomain6 localhost6
127.0.0.1       localhost.localdomain localhost
172.31.23.50    cache01h-t1
172.45.32.13    xenserv1.tcpromo.com
172.42.31.12    appserv1.tcpromo.com

Now using a script, i would like change the file as given in the snippet. Basically i want to make couple of changes.
1.  Add one additional line "172.31.27.72    tcprod.local    dc01h.tcprod.local" at the end.
2.  The line which contains the hostname of the system (here it is: 172.31.23.50    cache01h-t1) should be appended with the entry "<hostname>.tcprod.local"  (here it is: 172.31.23.50    cache01h-t1 cache01h-t1.tcprod.local)
Please note the hostname of the machine can be obtained by executing the command `hostname`.

Please help me.

Thanks,
AshokStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#::1            localhost6.localdomain6 localhost6
127.0.0.1       localhost.localdomain localhost
172.31.23.50    cache01h-t1 cache01h-t1.tcprod.local
172.45.32.13    xenserv1.tcpromo.com
172.42.31.12    appserv1.tcpromo.com   
172.31.27.72    tcprod.local    dc01h.tcprod.local
[+][-]07.08.2008 at 09:02PM PDT, ID: 21960519

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Perl Programming Language, Bourne-Again Shell (bash), Shell Scripting
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.08.2008 at 10:12PM PDT, ID: 21960745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 09:28AM PDT, ID: 21965511

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 09:59AM PDT, ID: 21965837

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.13.2008 at 09:48AM PDT, ID: 21993140

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628