I am trying to compile some sources using a makefile. In the makefile there is a bunch of commands that need to be ran as sudo
.
When I compile the sour
This error may also arise when you are trying to run a terminal command (that requires root password) from some non-shell script, eg sudo ls
(in backticks) from a Ruby program. In this case, you can use Expect utility (http://en.wikipedia.org/wiki/Expect) or its alternatives.
For example, in Ruby to execute sudo ls
without getting sudo: no tty present and no askpass program specified
, you can run this:
require 'ruby_expect'
exp = RubyExpect::Expect.spawn('sudo ls', :debug => true)
exp.procedure do
each do
expect "[sudo] password for _your_username_:" do
send _your_password_
end
end
end
[this uses one of the alternatives to Expect TCL extension: ruby_expect gem].