1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/usr/bin/ruby pattern = "/usr/bin/ruby" ps = Facter["ps"] regex = Regexp(pattern) ary = [] IO(ps) {|table| table {|line| if regex(line) ary = line(/^\s+/, '')(/\s+/) end } } ary[1] != nil ? ("Pid is: ") : ("Could not find the pid") |

