How to Take Input @ Startup Script

Hi There,

It didn't create input to enter home directory. Drive me nut?

clear
dir=/h/users/alex/bin
while ["$dir" != "home"]
do
  echo "Enter location of your home directory: "
  read input
  echo "$input: This is your home directory"
done  
LVL 1
suredazzleAsked:
Who is Participating?
 
TintinConnect With a Mentor Commented:
Please describe what you want your script to do and what is not working for you at the moment.
0
 
omarfaridCommented:
do you mean:

clear
dir=/h/users/alex/bin
while ["$dir" != "home"]
do
  echo "Enter location of your home directory: "
  read dir
  echo "$dirt: This is your home directory"
done
0
 
omarfaridCommented:
Sorry typo


clear
dir=/h/users/alex/bin
while ["$dir" != "home"]
do
  echo "Enter location of your home directory: "
  read dir
  echo "$dir: This is your home directory"
done
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
TintinCommented:
Your while test has a syntax error.  It needs spaces, ie:
while [ "$dir" != 'home' ]

Open in new window

0
 
suredazzleAuthor Commented:
Hi Omar Farid,

That's what the script suppose to say.

Do you have better suggestions?
0
 
omarfaridCommented:
I could not understand what you want to do with the script
0
 
suredazzleAuthor Commented:
Hi Omar Farid & Tintin,

Thanks! Fix the error. Need to apply brain surgery to write more. I know what it should look like. Need to play more. :)
0
 
suredazzleAuthor Commented:
Hi,

I want to create non-existence directory. Please advise solutions. Thanks.

clear
echo "Enter location of your home directory : "
read input

if [[ ! -d ~/h/susan ]] && echo "Directory ($input) does not exist."
   echo "Creating now....."
   mkdir -p ~/h/susan
   echo
else
echo "This is your home directory"  
fi

<<OUTPUT
Enter location of your home directory :
/h/susan
./test.sh: line 12: syntax error near unexpected token `else'
./test.sh: line 12: `else'
OUTPUT
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.