system
June 17, 2010, 12:43am
1
(imported topic written by JamesN91)
Goal - append the C:\WINDOWS\system32\drivers\etc\hosts file with a file containing a black list of ad sites.
Host file - C:\WINDOWS\system32\drivers\etc\hosts
Ad blacklist file - http://www.mvps.org/winhelp2002/hosts.txt
I want to set this so the action script appends the host with another file. I do not want to embed the blacklist file in the action script.
Something like this maybe???
if
(
exists file “C:\WINDOWS\system32\drivers\etc\hosts”
)
then
(
parameter “MVPS” = “http://www.mvps.org/winhelp2002/hosts.txt ”
waithidden cmd.exe /C echo {“type (parameter “MVPS”%0d%0a”} >> {(pathname of system folder as string & “\drivers\etc\hosts”)}
)
else
“Host File Not found”
Any help would be appreciated.
BenKus
June 17, 2010, 8:42am
2
(imported comment written by BenKus)
Maybe some helpful background here:
http://forum.bigfix.com/viewtopic.php?id=5039
Do you want to append to the end of the file or just overwrite it? If you append to it, are you going to run it multiple times (if so, it will re-append the big file each time).
Ben
system
June 17, 2010, 5:54pm
3
(imported comment written by JamesN91)
Thanks for the link to my own post
Append to the end of the file.
My issue is since the blacklist of ads is hosted externally, I do not know how to pull it down onto the local PC. Once I get it local I can print to screen each line of the blacklist file and append to the host file.
BenKus
June 18, 2010, 5:09am
4
(imported comment written by BenKus)
Oops…
You can do something like this:
// this command will download and cache the file on the server/relays each time you run the action
download http://www.mvps.org/winhelp2002/hosts.txt
waithidden cmd.exe /C type __Download\hosts.txt >> “{pathname of system folder}\drivers\etc\hosts”
Note that if you run this command multiple times, you will continue to add to the host file each time.
Ben
system
September 12, 2011, 10:57pm
5
(imported comment written by pdentremont91)
Hi Guys,
I’m trying to sink a server on macs and am getting an error.
Here is my shell command
#!/bin/sh echo 127.0.0.1 server.mydomain.com >> /private/etc/hosts
Here is the error.
11-09-12 2:43:19 PM com.bigfix.BESAgent
54
/bin/echo: /bin/echo: cannot execute binary file
Should I not be using echo to pipe the text? If not what is the proper syntax.
Thanks,
Peter d’Entremont
Noah
September 12, 2011, 11:30pm
6
(imported comment written by NoahSalzman)
If this is an Action Script you want:
waithidden /bin/sh -c "echo ‘127.0.0.1 server.mydomain.com ’ >> /private/etc/hosts "
If you are running this as a shell script I think you just want:
echo “127.0.0.1 server.mydomain.com ” >> /private/etc/hosts
Haven’t tested that myself…
system
September 12, 2011, 11:34pm
7
(imported comment written by pdentremont91)
Thanks Noah,
OK, I will try that I was just trying to confirm if there was a context issue running echo from terminal based on the error “can not execute binary file”.
Thanks,
Peter d’Entremont
Noah
September 12, 2011, 11:41pm
8
(imported comment written by NoahSalzman)
Just checked… it was the missing -c that was causing you trouble:
roquefort:~ noah$ /bin/sh echo ALL YOUR BASE ARE BELONG TO US
/bin/echo: /bin/echo: cannot execute binary file
roquefort:~ noah$ /bin/sh -c “echo ALL YOUR BASE ARE BELONG TO US”
ALL YOUR BASE ARE BELONG TO US
system
September 12, 2011, 11:49pm
9
(imported comment written by pdentremont91)
Thanks Noah,
Your a gentleman and a scholar!
Peter
system
September 13, 2011, 7:15pm
10
(imported comment written by pdentremont91)
Hi Noah,
I tried both the Shell script version and the action script version and neither have updated my host files. Any ideas? The action script version fails on the first line.
Thanks,
Peter d’Entremont
Noah
September 13, 2011, 11:49pm
11
(imported comment written by NoahSalzman)
Can you post a copy of your script so we can take a look?