I modified a bash_profile of "oracle" user. As I swith user from root to oracle user by
#su - oracle
it will ask for user input by displaying below statement
Select Version of Oracle [10G or 11G]:
Is there any way , If am not providing Input lets say for 5 seconds or 10 seconds it must take any default value; lets say either 10G or 11G. whatever I have mentioned in the code it should wait for input for 5/10 seconds if not provided by user code should provide automa开发者_开发技巧tically the default value. How can we handle this in the code.
Any help is appreciable.
echo -n "Oracle version (10g/11g)? "
read -t 10 VERSION || VERSION="10g"
echo $VERSION
For reference - bash read
command
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
read -t 10 -p "Select Version of Oracle [10G or 11G]:" version
if [ "$version" = "10G" || "$version" = "10g" ]
then
ORACLE_BASE=/data1/oracle10g
fi
export PATH=/usr/sbin:$PATH
echo $version
精彩评论