Tag Archives: SAMPLE

Read variable inputs

By newkid.7955

I am trying to make an interactive script. Only problem my inputs are not read and correctly channeled.

Please help:

Here is my code

Code:

#!/bin/sh
PATHSCRIPT=/home/pp/tmp

#if [ -z "$1" ]; then
# echo "Syntax : $0 input off lat sample"
# exit 1
# fi
echo "Choice of Graph"

echo "1 -- Type one graph 2 -- Type two graph 3 -- type three graph"

read num

if [[$num -eq 2]]; then

#echo " Enter arguments seperated with space: input off lat sample"
echo "Syntax : $0 input off lat sample"
#read $input $off $lat $sample
if [ $# -lt 2 ];
then
echo -e $HELP
exit 1
else
INPUT=$1
shift
OFF=$1
shift
LAT=$1
shift
SAMPLE=$1
shift
fi

else

if [[num==1]]; then
echo " Enter arguments seperated with space: input off lat sample"
#read $input $off $lat $sample

else

echo " Enter arguments seperated with space: input off lat sample"
#read $input $off $lat $sample
fi

fi


I keep receiving this error:


Choice of Graph
“1 — Type one graph 2 — Type two graph 3 — type three graph”
+ read num
2
+ [[2 -eq 2]]
./mastergraph_options.sh: 1: [[2: not found
+ [[num==1]]
./mastergraph_options.sh: 1: [[num==1]]: not found
+ echo Enter input off lat sample
Enter arguments seperated with space: input off lat sample

I cannot get past this place.
Please help me read the
–Choice 1,2 or 3
— channel it to the right format of files to be entered
:wall:

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums