WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Why won't busybox ash shell execute this little script but bash does?  (Read 22556 times)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
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

Code: [Select]
#!/bin/sh

function testport() {
if netstat -an | egrep ":$1 .*LISTEN" > /dev/null
then
return 0
else
return 1
fi
}
big pc man

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: Why won't busybox ash shell execute this little script but bash does?
« Reply #1 on: January 11, 2009, 10:07:42 PM »
Just use myfunction()
Having 'function' is redundant anyways :)

(it's probably a 'bashism')
« Last Edit: January 11, 2009, 10:09:39 PM by ^thehatsrule^ »

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Why won't busybox ash shell execute this little script but bash does?
« Reply #2 on: January 12, 2009, 09:08:13 AM »
Great! Thanks that fixed the problem.
big pc man