Should be simple this one but although I can do this in other languages I have yet to think of a good way using bash.
This is for an init script that may be run on a variety of redhat based systems, therefore it needs to be compatible with bash versions 3.2.25 and 2.05b and therefore cannot use bash regex matching.
Once the service has started I attempt to grab pid information using 'pidofproc' my issue is that sometimes this will output nothing (""), sometimes 1 pid ("1243") and sometimes multiple pids ("1243 8756") and I need to tell the difference between the 3 options.
if [ -z "$FCOMPID" ]; then
# do my pid is empty stuff
elif [ what_shall_i_put_here ]; then
# do i have too many pids stuff
# only 1 pid so do cool stuff
Solutions I have thought of are ugly or use perl or somesuch
pidofproc comes from redhat's init functions library.
I think this is the first time I've actually asked a question on this site
Of course, what would actually be handy is if the company we pay tens of thousands of pounds to for the software actually provided tools to use the software in a real environment. Sadly changing the software is a project for 2011, until then I have to play