I need to get the user input and execute a particular script based on the input provided.
For E.g. When I execute the script say Test.sh it should prompt "For which country I need to execute the script? (US/India)"
Based on the input as US or India from the user the execution of the steps in the script need to be done.
I have put some sample code can anyone please help me correct it and get the execution done successfully? How can I accept the user input ??
Code:
$ECHO $n "Enter the Country for which you want the installation to be executed? (US/India). $C"
if [ "${COUNTRY_SPEC}" = "US" -o "${COUNTRY_SPEC}" = "us"]
then
COUNTRY=US
else
COUNTRY=India
fi
echo -e "The installation is for $COUNTRY"
I have written the following code and the result as follows. Can you help? Thanks.
Code:
$ECHO $COUNTRY_SPEC "Enter the Country for which you want the installation to be executed? (US/India) $COUNTRY_SPEC"
read $COUNTRY_SPEC
if [ "${COUNTRY_SPEC}" = "US" -o "${COUNTRY_SPEC}" = "us"]
then
COUNTRY=US
else
COUNTRY=India
fi
echo -e "The installation is for $COUNTRY"
Result:
: No such file or directorye Country for which you want the installation to be executed? (US/India)
US
': not a valid identifier`
: command not found
./Test.sh: line 24: syntax error: unexpected end of file
Not sure why you are trying to use $ECHO variable to echo a message to the screen. If you are only trying to prompt the user to enter a value then use this:
echo "Enter the Country for which you want the installation to be executed? (US/India) "
read COUNTRY_SPEC
when im just trying to echo as mentioned by you:
echo "Enter the Country for which you want the installation to be executed? (US/India) "
read COUNTRY_SPEC