in reply to Quoting in Backtick
Are you sure that you want to invoke ps, grep and wc without a full path? This may be a security issue.
And why do you start five processes (shell, ps, 2x grep, and wc) where one is sufficient? grep and wc can easily be done in Perl, without a new process. The shell does not have to be invoked, you can use exec "/bin/ps","-ef";. You just have to read the output from that process, see Safe Pipe Opens in perlipc, especially the "safe backtick or pipe open for read" example. Replace the while loop in the parent process with an array read plus two Perl greps, and finally use scalar @array to get the line count.
|
|---|