Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Entering password in shell

Reply
Thread Tools

Entering password in shell

 
 
Eric C.
Guest
Posts: n/a
 
      12-01-2010
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

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Eric Christopherson
Guest
Posts: n/a
 
      12-04-2010
On Tue, Nov 30, 2010 at 7:07 PM, Eric C. <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
 
Eric C.
Guest
Posts: n/a
 
      12-05-2010
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

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP!] a doubt about entering password in python douxin Python 5 01-18-2013 06:36 AM
Entering username & password automatically using urllib.urlopen rodrigo Python 3 10-15-2007 03:33 AM
Password - How to avoid entering? John Brown Computer Support 5 07-11-2006 10:16 AM
Password entering system Tuvas Python 4 03-10-2006 02:42 PM
entering Password (a String) without leaving in-memory traces otf Java 5 11-29-2005 06:11 PM



Advertisments