having an issue when using case statement to search for multiple words in a txt file

9 views
Skip to first unread message

Spriya

unread,
Nov 24, 2014, 2:33:20 PM11/24/14
to puppet...@googlegroups.com
Hi All,

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?

Appreciate your help
Reply all
Reply to author
Forward
0 new messages