From: Eric Christopherson Date: 2010-12-05T03:48:21+09:00 Subject: Re: Entering password in shell On Tue, Nov 30, 2010 at 7:07 PM, Eric C. 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| >  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 sudo -v will prompt the user for the password ahead of time.