Are those caused by empty lines in the file your are iterating?
If so, you can try and add a
next if line.empty?
early in your log.each_line loop.
HTH,
Felix
On 11/25/2014 04:28 PM, Spriya wrote:
> Hi,
>
> I am trying to capture all paths in a text file. for that i am splitting
> the string into an array and the word with /java to get the paths.
>
> Here is my ruby code
>
> *logfile = "/home/weblogic/javaapp.txt"*
> *log = Facter::Util::FileRead.read(logfile)
> *
> *log.each_line do |line|
> *
> *unless log.nil?*
> *log.each_line do |line|*
> * val = line.split(/ /)*
> * java_path = val.grep(%r!/java!)*
> * java_count += 1*
> *Facter.add("java_known_weblogic_version#{java_count}") do*
> * setcode do*
> * java_path*
> end
> end
>
> Here is my text file
> */u01/java/jdk1.7.0_72/jre/bin/java*
> *
> *
> */u01/java/jdk1.7.0_72/bin/java*
> *
> *
> */u01/java/jdk1.7.0_65/jre/bin/java*
> *
> *
> */u01/java/jdk1.7.0_65/bin/java*