Hi Steenslang, thanks for your suggestion, but perhaps i was not entirely clear:
here is the complete snippet:
results = Array.new
f = open("messages", "r")
f.each_line do |line|
results << "#{$.} #{line}" if line =~ /error/
end
lastline = results.pop()
if ! results.empty?
# run shell command to email
Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|
ssh.exec(' hostname | /usr/local/bin/smtpclient -s lastline -S smtp.mail.com -v [email protected] > /my.out 2>&1') do|ch, stream, data|
end
now..... inside the ssh.exec() block i wand to use the "result" which is the last line , but ssh.exec(result) is not possible since ssh.exec is outside of the program flow and executing an external command.
I hope now it makes more sense , sorry for not clearly explaining the first time.