[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Shell login with IO.popen?

goodieboy

6/19/2007 6:46:00 PM

Hi,
Been messing around with IO and shell/system commands. I can't seem to
figure out why the first example works, and the second one doesn't.
Would someone be so kind and explain why this happens?

# WORKS
su = IO.popen("su - #{USERNAME}", 'w+')
su.puts PASSWORD
su.puts 'pwd'
su.close_write
puts su.readlines

# DOESN'T WORK
login = IO.popen("login", 'w+')
login.puts USERNAME
login.puts PASSWORD
login.puts 'pwd'
login.close_write
puts login.readlines

For the second one, I keep getting Invalid Login. Like it's not really
getting what I'm putting in to STDIN?

Thanks for helping out!