0

I dont know if it is weird that read is not taking the input from the terminal.

The configure script, which is used in source code making process, should ask the user to give the input to select the type of Database either MYSQL or ORACLE(below is the code).

MYSQLLIBPATH="/usr/lib/mysql" echo "Enter DataBase-Type 1-ORACLE, 2-MySQL (default MySQL):" read in echo $? >> /tmp/error.log if test -z "$in" -o "$in" = "2" then DATABASE=-DDB_MYSQL if true; then MYSQL_TRUE= MYSQL_FALSE='#' else MYSQL_TRUE='#' MYSQL_FALSE= fi echo "Enter Mysql Library Path: (eg: $MYSQLLIBPATH (default))" read in echo $? >> /tmp/error.log if test -n "$in" then MYSQLLIBPATH=`echo $in` fi echo "Mysql Lib path is $MYSQLLIBPATH" else if false; then MYSQL_TRUE= MYSQL_FALSE='#' else MYSQL_TRUE='#' MYSQL_FALSE= fi DATABASE=-DDB_ORACLE LD_PATH= fi 

But, the read command is not asking for the user input. Its failing to take the input from the stdin.

When I checked the status of the command in the error.log it was showing 1 1 

Could anyone tell why read is failing to take the input from the stdin. Are there any builtin variable which can block read taking the input?

3
  • What does read in >>/tmp/error.log emit? Commented Jul 27, 2013 at 7:08
  • @pts nothing, empty file Commented Jul 27, 2013 at 7:13
  • I think you have omitted some code from the middle, which redirects stdin. For example, putting exec </dev/null above the read in line would explain what you are observing, because in this case read in encounters an EOF, and sets $? to 1. Commented Jul 27, 2013 at 19:57

1 Answer 1

2

Most likely read executes with standard input redirected from a file that has reached EOF. If the above is not the whole of your configure code, check that there are no input redirections. Could the code above be a part of a function which was invoked with some input from a pipe or a file? Otherwise check how configure is executed - are there any redirections?

Otherwise, the universal advice applies: try simplifying and stripping down your code until it is obvious what's happening.

BTW, it is not a good idea to make configure interactive, if you want to have your program packaged for a distribution - it's not easy to control execution of interactive programs. Consider adding support for supplying parameters through command line options.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.