Does anyone know how to edit the hosts file on a mac with an agent procedure? PC is easy but the mac is killing me.
Additions or removals should be fairly easy with a shell script - echo "new stuff" >> /etc/hosts to add, or
cat /etc/hosts | grep -v "what to remove" > /tmp/hosts mv /tmp/hosts /etc/hosts to remove a line. If you want to inline edit multiple lines, look for examples using "sed" - the stream editor.
Create and test the script on the mac, then upload it to VSA. Use VSA to push the script down and then execute it. I would not try to do this directly with procedure commands.
Thanks for the info. it sounds like I have to write one line at a time. I have about 15549 entries to add so is there an easy way to just replace the hosts file on a mac?
Sure - just push the replacement file from the VSA. Sounds odd that you'd have that many entries in a Hosts file, though. What are you trying to do?
Replacing the file outright can have issues if the local hosts file had been customized.
The hosts file hasn't been customized yet.
When I find nafarious websites I tend to block them via the hosts file. It is quick and very easy to do on a windowns machine.
Just pushing is what I am trying to do. Alas I am not sure of the commands.
Thanks for trying to help.
For simple adds like that, the first example I posted should do the job.