Basic Error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Basic Error
# 1  
Old 09-05-2006
Basic Error

#!/bin/sh
read a
if ["$a" = apple] ; then
echo "ur good";
else
echo "ur bad"
exit
fi

I am getting the following error!

/home/xyz/scripts >help.sh
apple
help.sh[3]: [apple: not found.
ur bad

can i know what would be the wrong in my script
# 2  
Old 09-05-2006
Quote:
#!/bin/sh
read a
if ["$a" = apple] ; then
echo "ur good";
else
echo "ur bad"
exit
fi
Put space between [ and "$a" it should be like this:
Code:
if [ "$a" = apple ] ; then


Last edited by tayyabq8; 09-05-2006 at 07:27 AM.. Reason: Spelling....
# 3  
Old 09-05-2006
Ya thanks..that works

That works..
# 4  
Old 09-05-2006
Try this

read a
if [ $a = apple ]
then
echo "ur good"
else
echo "ur bad"
fi
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash on Fedora error on basic script

I am not able to execute bash script on Fedora. They were running on another environment. This is a sample script: #!/usr/bin/bash input="./data/heu/hout1" i=1 j=0 while IFS= read -r file1 do #Some code here done < "$input" #echo $j I get an error: bash: s.sh: command not... (3 Replies)
Discussion started by: ngabrani
3 Replies

2. Programming

Solr--Basic Example execution error

Hello , I am new bee to Solr and trying to run sample example for solr . java -Durl=http://locahost:8983/solr/update -jar post.jar books.csv Error SimplePostTool version 1.5 Posting files to base url http://locahost:8983/solr/update using content-type... (3 Replies)
Discussion started by: Tomlight
3 Replies

3. UNIX for Dummies Questions & Answers

basic if else

I know this is pretty basic, but i cant figure it out to save my life. i want it to ask for a variable, as long as that variable isnt -/0 i want it to print out the area. else if the variable is -/0, i want it to print out invalid entry. the only problem is it will still try to print out the... (1 Reply)
Discussion started by: cookiebooy
1 Replies

4. UNIX for Dummies Questions & Answers

basic question about error report in AIX

Hello everybody, iam new to unix. here is a question i had. when i run errpt -a , sample out put is as follows LABEL: FCP_ARRAY_ERR4 IDENTIFIER: D5385D18 Date/Time: Mon Sep 25 11:15:59 Sequence Number: 182869 Machine Id: 000166784C00 Node Id: ... (0 Replies)
Discussion started by: karthikosu
0 Replies

5. UNIX for Dummies Questions & Answers

Need some basic help

Hi everyone, I need some help! I know that this is a very simple little problem but I seem to be stuck. I was just wondering if you could show me the right way. I basicly have to write a single line of commands (using piping) to do the following: From the file data.txt, select all of the... (2 Replies)
Discussion started by: itk
2 Replies

6. HP-UX

Bt-basic

Hi Guys, I very new to bt-basic even I got 8 years experience on UNIX. I searched through google about bt-basic but nothing really give me solid documentation. Anybody have documentation or manual for this bt-basic? Pls help me (2 Replies)
Discussion started by: shahru
2 Replies

7. What is on Your Mind?

Basic...

hi, I am pretty new both to unix and this forum, can anyone help me to give shortcuts to my commands... eg:- instead of "cd /usr/bin" i want to to give " bin " and get to that path. I'm using HP-UX 11.0 abey (2 Replies)
Discussion started by: abey
2 Replies

8. UNIX for Dummies Questions & Answers

Basic

hi, I am pretty new both to unix and this forum, can anyone help me to give shortcuts to my commands... eg:- instead of "cd /usr/bin" i want to to give " bin " and get to that path. I'm using HP-UX 11.0 abey (2 Replies)
Discussion started by: abey
2 Replies
Login or Register to Ask a Question