I've hunted around for an answer to why the busybox ash shell won't execute this little script (actually just a function of a larger script) but the bash shell will. I wonder if there is a simple change that would make it acceptable for the ash shell. Anyway since there are so many experts on this forum I thought someone would know the answer. The error message is:
./test: line 3: syntax error: "(" unexpected
#!/bin/sh
function testport() {
if netstat -an | egrep ":$1 .*LISTEN" > /dev/null
then
return 0
else
return 1
fi
}