Entering password in shell

E

Eric C.

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
 
E

Eric Christopherson

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|
=A0stdout.write("#{pass}\n")
=A0puts stdin.read.lstrip =A0#write output to screen
end

This works fine if the password is correct. =A0However, if the password i= s
not correct it hangs. =A0I've tried this line too:

=A0stdout.write("#{pass}\n\n\n\n\n\n")

to try to get it to terminate, but it still hangs. =A0Is 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.
 
E

Eric C.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top