abhi655
abhi655

Reputation: 55

how to map shell command line arguments to READ command

My program takes in 2 arguments from a user

echo "Enter First code :"; read code_1
echo "Enter Second code :"; read code_2

I Run test.ksh and it prompts for user input.

Say user inputs 1 and 2

Enter First code : 1
Enter Second code : 2

Now without editing test.ksh how do I map arguments passed at command line to read statements inside my shell script ?

test.ksh 1 2

Enter First code : 1
Enter Second code : 2

Upvotes: 0

Views: 484

Answers (1)

chepner
chepner

Reputation: 531758

You don't; you write the values to your scripts standard input instead.

printf '1\n2\n' | test.ksh

Upvotes: 1

Related Questions