I am trying to search for multiple words in a text file. But it is not returning any output.
logfile = "/home/weblogic/javaapp.txt"
java_count = 0
if File.exist? '/home/weblogic/javaapp.txt'
log = Facter::Util::FileRead.read(logfile)
unless log.nil?
log.each_line do |line|
case
when line.include?('/java')
java_count += 1
java_path = line.split(/ /)[0]
when line.include?('java version')
java_version = line.split('"')[1]
Facter.add("java_u01_weblogic_foundversion#{java_count}u01_#{java_count}_path") do
setcode do
java_version + java_path
end
end
end
end
end
But if use only one when statement it is working. Let me know search for two words at the same time?