Hello, everyone!
I'm trying to write a small script to be executed after OpenVZ
container creation. Everything goes fine until I need a user input.
Here is the code:
Code:
while [ "$var_ans" != "y" ] && [ "$var_ans" != "n" ]; do
echo -n "Would you like to configure 2 veth interfaces (DMZ
setup) inside the container? [y/n] "
read -e var_ans
done
When I run this script manually ( ./script.sh ), the input is
performed normally, the variable is set and everything is OK. But when
the script is run by a program ("vzctl" in my case), I'm getting
errors like these in the terminal:
Code:
/etc/vz/dists/scripts/postcreate_sles11.sh: line 137: read: read error: 0: Bad file descriptor
And the "while" loop continues, producing these messages until I kill
the script. So, where is the pitfall? Is this because the script isn't
run directly from the terminal (by vzctl program) or because all this
is done by SSH? May be, I should use any other input method in this
case?
Version info:
Code:
GNU bash, version 3.2.48(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
If any additional info is required, let me know.
Thank you.