1

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 automatically the default value. How can we handle this in the code.

Any help is appreciable.

2
  • This Is what I coded in .bash_profile. It will ask for Version of Oracle.So can we just wait and force to set a default value if user is taking more than 5/10 seconds **********************************************************************# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi PATH=$PATH:$HOME/bin echo -n "Select Version of Oracle [10G or 11G]:" read Oversion version=$(echo $Oversion | tr [:lower:] [:upper:]) if [ "$version" = "10G" ] then ORACLE_BASE=/data1/oracle10g; export ORACLE_BASE PATH=/usr/sbin:$PATH; export PAT echo $version Commented Mar 8, 2011 at 7:12
  • 1
    As a user, I would prefer that you pick a default, assign it, emit a message indicating that it has been assigned, and let me take an action to change it if desired. Timed out interaction in a .bashrc is as annoying as confirmation pop-up windows or clippy. Commented Mar 8, 2011 at 12:30

2 Answers 2

2
echo -n "Oracle version (10g/11g)? "
read -t 10 VERSION || VERSION="10g"
echo $VERSION

For reference - bash read command

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

Comments

0
# 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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.