Well, in that case i will leave my contribution with the function we use here to count running instances of a given program, using a Linux command...
You basically do a ps -ef and grep the program name, read the response and discard lines with the program name that don't actually indicate that the program is running. Replace <program name> with the name of the program you want to count.
private function count()
define l_command string
define l_line string
define ch base.Channel
define l_count smallint
define l_aux string
let l_count = 0
let ch = base.Channel.create()
let l_command = 'ps -ef | grep <program name>'
call ch.openPipe(l_command, "r")
while ch.read(l_line)
if l_line.getIndexOf("gsproxy-bin",1) > 0 or
l_line.getIndexOf(l_aux,1) > 0 or
l_line.getIndexOf("sh -c ps -ef",1) > 0 or
l_line.getIndexOf("grep <program name>",1) > 0
then
continue while
end if
let l_count = l_count + 1
end while
call ch.close()
return l_count
end function