Hi,

when i am trying to count the lines in how many  locations the java is. It 
is giving me wrong count. 

Here is my code:
*require 'facter'*
*require 'facter/util/file_read'*

*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|*
*   val = line.split(' ')*
*    java_path = val.grep(%r!/java!).join(',')*
*    java_version = val.grep(%r!/java!).map{ |s| s[/\d+\.[a-z\d._-]+/] 
}.join(',')*
*    java_count += 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*

*Facter.add("java_u01_weblogic_foundversion_count") do*
*    setcode do*
*      java_count*
*     end*
*    end*


Here is my txt file
*/u01/java/jdk1.7.0_72/jre/bin/java*
*java version "1.7.0_72"*
*Java(TM) SE Runtime Environment (build 1.7.0_72-b14)*
*Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)*
*/u01/java/jdk1.7.0_72/bin/java*
*java version "1.7.0_72"*
*Java(TM) SE Runtime Environment (build 1.7.0_72-b14)*
*Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)*
*/u01/java/jdk1.7.0_65/jre/bin/java*
*java version "1.7.0_65"*
*Java(TM) SE Runtime Environment (build 1.7.0_65-b17)*
*Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)*
*/u01/java/jdk1.7.0_65/bin/java*
*java version "1.7.0_65"*
*Java(TM) SE Runtime Environment (build 1.7.0_65-b17)*
*Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)*

*Here is my facts*

java_u01_weblogic_foundversion13u01_13_path
1.7.0_65/u01/java/jdk1.7.0_65/bin/java
java_u01_weblogic_foundversion1u01_1_path
1.7.0_72/u01/java/jdk1.7.0_72/jre/bin/java
java_u01_weblogic_foundversion5u01_5_path
1.7.0_72/u01/java/jdk1.7.0_72/bin/java
java_u01_weblogic_foundversion9u01_9_path
1.7.0_65/u01/java/jdk1.7.0_65/jre/bin/java
java_u01_weblogic_foundversion_count16
The count should be 4 but it is giving me 16 locations. Can anyone help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/7ef2d1ee-7c32-4f55-b397-a06c5847c0f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to