Removing hostnames doesnt work
menecken opened this issue · comments
Bernhard Schlegel commented
From batch nothing happens from nodeJS-App it messes up the file around the entry that should be deleted (missing linebrakes). I'm on rapsbian.
Code I'm using
var preserveFormatting = false
hostile.get(preserveFormatting, function (err, lines) {
if (err) {
console.error('getting lines failed: ' + err.message)
}
lines.forEach(function (line) {
console.log("found line with ip=" + line[0] + " and entry=" + line[1]);
if (line[0] == "127.0.1.1")
{
console.log("removing line with ip=" + line[0] + " and entry=" + line[1]);
hostile.remove(line[0], line[1] , function (err) {
if (err) {
console.error('removing etc/hosts/ failed: ' + err)
} else {
console.log('removed /etc/hosts successfully!')
}
})
}
})
})
Feross Aboukhadijeh commented