I'm trying to run multiple instances of a node server using a bash script. I parametrized node such that I could change the port at each cycle, but it seems I cannot run it properly. This is what I wrote (and doesn't start anything). It looks pretty ugly, I'm very new to bash scripting.
#!/bin/bash
#iterate input times and start server
COUNT=$1
TIMEOUT=$2
PORT=3000
while [ $COUNT -gt 0 ]; do
A="node server.js "
B=PORT
C=" "
D=TIMEOUT
CMD=$A$B$C$D
$CMD
let PORT=PORT+10
let COUNT=COUNT-1
done
TIMEOUT is just another variable that I pass to the server instance.
Can anyone point out what am I doing wrong? Thanks a lot, and sorry if the script looks ugly.