Hi!
I'm kind of a n00b at bash scripting (read: long time since my last bash script), and have a (probably) simple Q:
I've made a script with some functions but I'm unable to catch their return value...
Example:
------------------------------------------------------
getNumInst() {
ps auxww | grep azureus | while read OUTP1
do
let "i+=1"
nrInst=$i
done
return $nrInst
}
instances=$(getNumInst)
echo "Instances of Azureus: $instances"
-------------------------------------------------------
Before you ask why I do this as a function: I've also tried it as a simple while loop, but with the same result.
I guess its got something to do with integer values in strings, or something...
But the strange thing is that if I put an echo "Count: $nrInt" before "done", it will show the current value of $nrInst. But if I put it after done, there's no value (as in "" or null). I've also tried "declare nrInst" and "declare -i i" without a positive result...
So what am I doing wrong? Can someone please help me with this?
PS! I'm trying to write this because every now and then Azureus shuts down, and I don't want to check it and restart it every time it happens...