Expecr error help!

Hi Ruby folks!

Any ideas? Output and error is below at __OUT__
Also I am fairly new to Ruby...coming from Perl, so what does the
w_f.sync do?
thank u!

#!/usr/bin/env ruby -w

require 'pty'
require 'expect'

DN = "/usr/local/bmc/controlm/ctmagt/ctm/scripts/shut-ag"
UP = "/usr/local/bmc/controlm/ctmagt/ctm/scripts/start-ag"

STDOUT.sync = true
STDERR.sync = true
$expect_verbose = true
prompt_pat = %r/^\sEnter CONTROL-M.*/m

if ARGV.empty?
   $stderr.puts "A argument of -stop or -start is required, bye!"
   exit 1
end

if ARGV[0] == '-stop'
   Dir.chdir("/usr/local/bmc/controlm/ctmagt/ctm/scripts")
   puts Dir.pwd
   puts "\nNow shutting down controlM, please wait...\n"
   PTY.spawn("#{DN}") do |w_f|
      w_f.sync = true
      w_f.expect(prompt_pat){ w_f.puts "ctmagt" }
      w_f.expect(prompt_pat){ w_f.puts "ALL" }
   end
end

__OUT__

# ruby cntrlM_recycle.rbx -stop
/usr/local/bmc/controlm/ctmagt/ctm/scripts

Now shutting down controlM, please wait...
open: pty slave: No such file or directory

···

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

Derek Smith wrote:

Any ideas? Output and error is below at __OUT__

What platform are you on - operating system type and version, ruby type
and version?

Also I am fairly new to Ruby...coming from Perl, so what does the
w_f.sync do?

same as autoflush() in Perl

···

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

Brian Candler wrote:

Derek Smith wrote:

Any ideas? Output and error is below at __OUT__

What platform are you on - operating system type and version, ruby type
and version?

Also I am fairly new to Ruby...coming from Perl, so what does the
w_f.sync do?

same as autoflush() in Perl

# ruby -v
ruby 1.8.7 (2009-04-08 patchlevel 160) [hppa2.0w-hpux11.23]
root@blight [/home/xxxx/scripts/ruby]
# uname -a
HP-UX blight B.11.23 U 9000/800 1162444665 unlimited-user license

ok thank you!

···

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

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/.

Derek Smith wrote:

HP-UX blight B.11.23 U 9000/800 1162444665 unlimited-user license

Then it looks like the PTY library doesn't work properly under HP-UX. If
you can make a small test case which works under Linux but fails under
HP-UX, then you can take it to ruby-core or redmine.ruby-lang.org

···

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