Forum: Ruby Shell login with IO.popen?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
444c7d8579d3389a76c8497f5cb66c13?d=identicon&s=25 M.W. Mitchell (goodieboy)
on 2007-06-19 20:46
(Received via mailing list)
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!
This topic is locked and can not be replied to.