This is a crude script I wrote in an application called CodeRunner, on Mac OS X. It works flawlessly when I run it within CodeRunner's built-in execution environment, but just sits there - presumably in a loop - anywhere else (ie: within Mac OS's own terminal or in a bash terminal on a RedHat Enterprise Linux system I have at work).
It takes arguments from the user and searches for them in a CSV file. When found in the file, it returns the rest of the line (where those args were found) to form a command structure used in another application.
I'm not exactly new to shell scripting, but seldom do it. Does anyone have any ideas as to what's wrong here?
Thanks
test.sh:
Code:
#!/bin/bash
read $1 $2 $3 $4
# This reads the CSV file, splitting each line.
while IFS=',' read WHERE FEED TYP TRANSPORT SRC
do
if [[ "$1" == "$WHERE" || "$1" == "$WHERE" ]] && [[ "$2" == "$FEED" && "$3" == "$TYP" ]]
then
mlisten="./mamalistenc -tport $TRANSPORT -S $SRC -s $4 -m lbm -dict_tport dict_prod\n"
break
elif [[ "$1" == "$WHERE" && "$2" == "$FEED" && "$3" == "$TYP" ]]
then
mlisten="./mamalistenc -S $SRC -s $4 -tport $TRANSPORT -m lbm -dict_tport dict\n"
break
else mlisten="Feed or Type wasn't found in the database\n"
fi
done < transports.txt
echo -e "$mlisten"
transports.txt
CHI,ASX,MT,ctf_asx1_tport,CTF_ASX_CHI1
CHI,ASX,DB,ctf_asx1_db_tport,CTF_ASX_CHI1_DB
HOU,ASX,MT,ctf_asx1_tport,CTF_ASX_PROD1_HOU1
HOU,ASX,DB,ctf_asx1_db_tport,CTF_ASX_PROD1_HOU1_DB
LON,ASX,MT,ctf_asx1_QA_tport,CTF_ASX_LON11
LON,ASX,DB,ctf_asx1_db_QA_tport,CTF_ASX_LON1_DB
USAGE:
./scipt.sh <WHERE> <FEED> <TYPE> <SYMBOL>
e.g. ./script.sh LON ASX MT MY_SYMBOL
A successful run, using the command above, should display the following:
./mamalistenc -tport ctf_asx1_QA_tport -S CTF_ASX_LON11 -s MY_SYMBOL -m lbm -dict_tport dict_prod