Need help: Script to edit the hosts, network and eth0 file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help: Script to edit the hosts, network and eth0 file
# 1  
Old 07-22-2008
Error Need help: Script to edit the hosts, network and eth0 file

Hello all Smilie

I am new to scripting. I need somebody to help me write a script that can edit the files.
For eg: if i say ./script <ipadd> <hostname>
then it should change the ipaddress and hostname in the following files:
1. /etc/hosts
2. /etc/sysconfig/network
3. /etc/sysconfig/network-scripts/ifcfg-eth0

I have just started scripting so any help would be greatly appreciated.
Thanks all in advance.
Cheers Smilie
# 2  
Old 07-22-2008
If you use perl it would be good option. Playing with files is always easy with perl.

- nilesh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

2. Linux

Is possible to bridge wlan0 and eth0 using network manager?How to for wpa?

I have created a bridge with nmcli between eth0 and wlan0 I use this procedure sudo nmcli con add ifname br0 type bridge con-name br0 sudo nmcli con add type bridge-slave ifname eth0 master br0 sudo nmcli con add type bridge-slave ifname wlan0 master br0 sudo nmcli con modify br0... (1 Reply)
Discussion started by: Linusolaradm1
1 Replies

3. UNIX for Advanced & Expert Users

File edit script exceptions how to pass to script

i wrote script for if file exists script do file edit problem with the script get stuck not existing as for exit i mentioned exit 0 , and how to give the exception for script it should add ./script -- add hi ./script --add "hi how are you" now below script with case it is working for... (0 Replies)
Discussion started by: markjohn1
0 Replies

4. IP Networking

Help with to check the tcp network connectivity between servers and hosts

ello, i am new to the networking side. I have a requirement to check the tcp network connectivity between server it's running on and the list of host's and ports combination. please help me where i am going wrong. my code: #!/bin/bash #read the file line by line cd "$1" cat... (17 Replies)
Discussion started by: sknovice
17 Replies

5. Shell Programming and Scripting

Ssh to 100s of hosts with password in a shell script or text file

I have about 500 hosts where I need to ssh by sending the password on the command line or in a text file in a clear text . However I am not able to download "sshpass" or other tools . Any other ways to pass the password in a script ? (3 Replies)
Discussion started by: gubbu
3 Replies

6. Red Hat

Unable To Activate Ethernet Network Device in RHEL 5.5 - e100 device eth0 does not seem to be presen

Hi All, Could anyone please help to resolve the below problem. I installed RHEL5.5 in my desktop.But when i try to activate the ethernet connection then it gives me the error. I spent 2 days for the above and go through with several suggestion found by googling. But no luck. ... (0 Replies)
Discussion started by: Tanmoy
0 Replies

7. Red Hat

SSH broke and network traffic / talking issue between hosts and server

Ok Time warner cable / voip modem feeding Cisco PIX 501 Wan port from PIX 501 LAN port to WAN port on Linksys wrt54GL wireless router. so -->Modem-->PIX 501-->WRT54GL-->Linux Server, wireless desktop, wireless laptop (2), Wireless MAC Pro, Wireless Apple TV, Wireless printer. my... (0 Replies)
Discussion started by: tedeansiii
0 Replies

8. Red Hat

[tip] network route-eth0

hi, i would like to share this /etc/sysconfig/network-script/route-eth0 GATEWAY0=XXXXXX NETMASK0=XXXXXX ADDRESS0=XXXXXXX a delete route command with "route del -net xxxx...." will work but if the above exist and you reboot the linux then old route will be invoke on that config-route. ... (0 Replies)
Discussion started by: itik
0 Replies

9. Shell Programming and Scripting

How to EDIT file using VI in a script

Hello, How would i go about editing a file using VI within a shell script please? Basically, i want to open a file, clear it's contents and save the file. I found this on the web using "ex" but can't seem to get it to work: ex /home/oconnor/TOOLS/UNIXCMDS/test_ex <<eof_ex dd /*i put... (2 Replies)
Discussion started by: bobk544
2 Replies

10. UNIX for Dummies Questions & Answers

edit /etc/hosts to show mypc in who

have edit the /etc/hosts as belows 123.45.12.55 mypc so when i do a who, i can see my "mypc" BUT after i changed, i cant see "mypc" do i have to restart anything? (6 Replies)
Discussion started by: yls177
6 Replies
Login or Register to Ask a Question