Bash Posix Compliance



Hi

Another day, another problem. I have the following shell script :

NOTE : SERVERIP is an env variable. This is a comma-separated
ip-address:port combination like x.x.x.x:y,x.x.x.x:y,x.x.x.x:y

----------------------------------------------------------------------------------------------------------------------------
#!/bin/sh

# Determine the number of servers
SERVER_COUNT=`echo $SERVERIP | tr ',' '\012' | wc -l | cut -d ' ' -f8`
echo "Server Count : $SERVER_COUNT"

# For each server, get the ip address and port
for ((index = 1 ; index <= $SERVER_COUNT ; index++))
do

# Get the port and IP address of each server
SERVER=`echo $SERVERIP | cut -d',' -f$index`

done
----------------------------------------------------------------------------------------------------------------------------

When i run this script like so...

$ . servers.sh

this works fine. However, If I use the sh -x command ($ sh -x
servers.sh), I get the following error:

+ echo
+ tr , \012
+ wc -l
+ cut -d -f8
SERVER_COUNT=1
+ echo Server Count : 1
Server Count : 1
servers.sh: syntax error at line 9: `(' unexpected

I've also tried changing the first line to #!/bin/bash but I get the
same error. This is on Solaris 5.9. Can anyone help?

Thanks in advance,
Rajiv

.



Relevant Pages

  • Re: public key file problems
    ... I copy it to the server by rsync (shell script) ... On the server a file parses the key file and appends the content to ... I'm also able to copy a file by scp with no password prompt (scp test3 ...
    (alt.os.linux.suse)
  • shell script - telnet port 25
    ... I am trying to write a shell script which keeps checking for smtp ... server with "telnet smtp.test.com 25" ... Unless i type quit it hangs there and can't grep 220. ...
    (comp.unix.shell)
  • shell script - telnet port 25
    ... I am trying to write a shell script which keeps checking for smtp ... server with "telnet smtp.test.com 25" ... Unless i type quit it hangs there and can't grep 220. ...
    (comp.unix.shell)
  • public key file problems
    ... I copy it to the server by rsync (shell script) ... On the server a file parses the key file and appends the content to ... I'm also able to copy a file by scp with no password prompt (scp test3 ...
    (alt.os.linux.suse)
  • public key problems
    ... I copy it to the server by rsync (shell script) ... On the server a file parses the key file and appends the content to ... I'm also able to copy a file by scp with no password prompt (scp test3 ...
    (comp.os.linux.networking)