jdamae
jdamae

Reputation: 3909

unix - how to construct IFS for passing in context of file

Am I constructing this properly? I can't figure how to debug this. Basically, I'm trying to pass in a text file (login.info):

foo
bar

To this shell script to be used as parameters like so:

#/usr/bin/ksh

#Base dir
BASEDIR=/home/scripts
export BASEDIR;

#Key
KEY=$BASEDIR/login.info
export KEY;

IFS="
"
arr=( $(<$KEY) )
echo "username=${arr[0]} password=${arr[1]}"

Getting this error:

./tst.sh[12]: Syntax error at line 12 : `(' is not expected.

Upvotes: 0

Views: 58

Answers (1)

Barmar
Barmar

Reputation: 781944

It seems like your version of ksh doesn't understand (...) in array assignment. Maybe this will work better:

set -A arr $(cat $KEY)

Upvotes: 1

Related Questions