Hi,
i have to run a Ruby script by cron.
When the script is runned in a shell, all is ok but when the script is
runned by cron i have a strange error:
/usr/lib/ruby/1.6/expect.rb:13:in select': Child_changed: 308 (RuntimeError) from /usr/lib/ruby/1.6/expect.rb:13:in
expect’
from /usr/local/bin/get_all.rb:11:in scp' from /usr/local/bin/get_all.rb:9:in
spawn’
from /usr/local/bin/get_all.rb:9:in `scp’
from /usr/local/bin/get_all.rb:39
I have the following code:
···
#!/usr/bin/ruby
require ‘pty’
require ‘expect’
TMP_DIR = “/cache/tmp”
def scp(host, login, passwd, file)
PTY.spawn("/usr/bin/scp #{login}@#{host}:#{file} #{TMP_DIR} 2> /cache/tmp/err
/cache/tmp/autre"){|rio, wio, pid|
wio.sync = true
rio.expect(/ password:/){
wio.print(passwd,“\n”)
}
begin
rio.gets while 1
rescue
puts “fini”
end
}
end
I’m running ruby 1.6.7
[follc@slishub /cache/tmp]$ ruby -v
ruby 1.6.7 (2002-03-19) [i386-linux]
What is the problem ? (and the solution ? ;-))
Regards