Hi,
How can I prompt a user for two input and pass the input to variables in the script. I have the following script but it is not working:
+++++++++Begin+++++++++++
#!/bin/sh
database_c=$1
output_f=$2
echo "Your db is $1\nOutput is $2"
+++++++++End+++++++++++
Thanks,
Leonard
jaduks
2
Is this ok ?
$ cat prompt.sh
#!/bin/sh
NOARG=64
f_Usage()
{
echo "Usage: `basename $0` <database> <Output>"
exit $NOARG
}
[ $# -lt 2 ] && f_Usage
database_c=$1
output_f=$2
printf "Your db is $1\nOutput is $2"
<Two args are passed, ok>
$ sh prompt.sh mysql ss
Your db is mysql
Output is ss
<Only one arg is passed, not ok, prompt>
$ sh prompt.sh mysql
Usage: prompt.sh <database> <Output>
<None of the args are passed, prompt>
$ sh prompt.sh
Usage: prompt.sh <database> <Output>
no. I want the user to be prompted when the script is invoked. Not passing the value to the script.
#!/bin/sh
echo 'Enter database:'
read database_c
echo 'Enter output:'
read output_f
echo "Your db is $1\nOutput is $2"