2

I am trying to edit hosts file. But it gives error:

sudo: no tty present and no askpass program specified.

I have tried but its not working. Please help if anyone know. Thank You.

NSMutableString* pfConf = [NSMutableString stringWithContentsOfFile: @"/private/etc/pf.conf" encoding: NSUTF8StringEncoding error: nil];
if ([pfConf rangeOfString: @"/private/etc/pf.anchors/org.eyebeam"].location == NSNotFound) {
  [pfConf appendString: @"\n"
   "anchor \"org.eyebeam\"\n"
   "load anchor \"org.eyebeam\" from \"/private/etc/pf.anchors/org.eyebeam\"\n"];
}
[pfConf writeToFile: @"/private/etc/pf.conf" atomically: true encoding: NSUTF8StringEncoding error: nil];
Mihriban Minaz
  • 3,043
  • 2
  • 32
  • 52
  • 1
    Possible duplicate of [How to fix 'sudo: no tty present and no askpass program specified' error?](http://stackoverflow.com/questions/21659637/how-to-fix-sudo-no-tty-present-and-no-askpass-program-specified-error) – CaptJak Feb 16 '16 at 16:23
  • Thanks @Mihriban Minaz. Yes, I get it. But I am new to this. So do you know how to edit pf.conf without using sudo in our programming. I mean I would like to use some built in function. Please reply if you know. – Nikhil Pande Feb 17 '16 at 11:17

0 Answers0