Entering password in shell

HI:

I’m trying to run a shell to install a gem:

PTY.spawn(“sudo gem install #{gem} --local 2>&1”) do |stdin,stdout,pid|
stdout.write("#{pass}\n")
puts stdin.read.lstrip #write output to screen
end

This works fine if the password is correct. However, if the password is
not correct it hangs. I’ve tried this line too:

stdout.write("#{pass}\n\n\n\n\n\n")

to try to get it to terminate, but it still hangs. Is there a way to
enter passwords into the command line or enter them ahead of time?

Thanks,
Eric

On Tue, Nov 30, 2010 at 7:07 PM, Eric C. [email protected]
wrote:

not correct it hangs. I’ve tried this line too:

stdout.write("#{pass}\n\n\n\n\n\n")

to try to get it to terminate, but it still hangs. Is there a way to
enter passwords into the command line or enter them ahead of time?

Thanks,
Eric

sudo -v will prompt the user for the password ahead of time.

Hi:

Thanks for your response. However, I don’t think that using the -v
option works.

I may not need to do it anyway because the process I was trying to do
was install a gem on my local machine:

sudo gem install xxxx.gem

I found that you can require rake, and do a better job:

require ‘rake’

Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end

I don’t know how this works, I’m trying it now. Thanks for help,

Eric