From: Derek Smith Date: 2010-08-07T03:03:23+09:00 Subject: Re: expecr error help! I even tried the passwd command code copied from this site in someone else's post and I get a similar error: # ruby -d cntrlM_recycle.rbx Exception `LoadError' at /opt/iexpress/rubyrails/lib/ruby/site_ruby/1.8/rubygems.rb:1113 - no such file to load -- rubygems/defaults/operating_system Exception `LoadError' at /opt/iexpress/rubyrails/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:50 - no such file to load -- Win32API Exception `NoMethodError' at /opt/iexpress/rubyrails/lib/ruby/1.8/rational.rb:78 - undefined method `gcd' for Rational(1, 2):Rational Old password:test New password:scifi open: pty slave: Is a directory __CODE__ #!/usr/bin/env ruby -w require 'pty' require 'expect' print 'Old password:' old_pwd = gets.chomp print "\nNew password:" new_pwd = gets.chomp PTY.spawn('/usr/bin/passwd katty') do |read,write,pid| write.sync = true $expect_verbose = false # You can use regular expressions instead of strings. The code block # will give you the regex matches. read.expect(/Changing password for katty\nNew password: /, 5) do |response, *matches| write.print new_pwd + "\n" if response end # The default value for the timeout is 9999999 seconds read.expect("Re-enter new password:") do |response| write.puts new_pwd + "\n" if response end end -- Posted via http://www.ruby-forum.com/.