D
Derek Smith
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
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