redsox01532
asked on
script to edit hosts file
Is is possible to edit the hosts file with a script that the user can run from their machine. One of our groups needs to remove the # symbol from one line in the hosts file. The line is:
# 127.0.0.1 localhost
I want to get a script that the user can run that will remove the # symbol from that line.
Any help is much appreciated.
# 127.0.0.1 localhost
I want to get a script that the user can run that will remove the # symbol from that line.
Any help is much appreciated.
sed -i.bak '/127.0.0.1/s/#//' hostsfile
ASKER
how would I have the users run this from their pc's? do I save it as a .bat file or simply run it from the command prompt?
make a new file with no # in it
Then copy that file remotely to all the machines in the given locations replacing the old file or rename the file first then copy
Then copy that file remotely to all the machines in the given locations replacing the old file or rename the file first then copy
ASKER
I thought of doing this but a some of the users are field users. I was hoping to have them run a script from their machine that would do this for them. Not sure if that is possible. They need this b/c they are installing an application that needs the # removed from that line in order to work.
Copy the following line into .bat file then ask them to open it which will do the trick
echo "127.0.0.1 localhost" >> C:\Windows\System32\driver s\etc\host s
echo "127.0.0.1 localhost" >> C:\Windows\System32\driver
ASKER
thanks. that added the entry but it didnt remove the # 127.0.0.1 local host entry. do i need to add something to the bat to do that as well?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great. Thank you.