passing Argument

Hi All,

i have script like below..

echo "1) first option"
echo ""
echo "2) second option"
echo ""
echo "*) please enter the correct option"

read select
case $select in
1) echo "first option selected"
;;
2) echo "second option selected"
;;
*) echo "please enter the correct option"
;;

here i want to give the options as para meter in script..to make it cron..

can any one help me out how the script can be modified..

?

Thanks in advance
Sha

select=$1

if [ "$select" = "" ]
then 

echo "1) first option"
echo ""
echo "2) second option"
echo ""
echo "*) please enter the correct option"

read select
fi

case $select in
1) echo "first option selected"
;;
2) echo "second option selected"
;;
*) echo "please enter the correct option"
;;

$1 is the first arg...

Hope this helps.

  1. comment out all the stuff that is for user input only (i.e. the echo statements, and the logic that follows)
  2. test for the existence of command line parameters
  3. test that the command line parameter(s) are within acceptable limits
  4. use the parameter(s) as input to the "doing" section of the script (which you haven't shown)

Hi ..

Thanks for your quick replay..
it works ....excellent..

:slight_smile:

regards
Sha

hi wempy

Thanks for your valid suggestion..

Yes now i am using the argument principle..

it works :slight_smile:

Thanks