Juice
Juice

Reputation: 111

If always gives same result, even if condition is true or false

I need to have my input validated and receive a valid output based on the condition being true or false. Here even if my condition is true, I still get the false output. Where is my code wrong?

#
set input

#read -p "Who wrote the book Roots?" : input

#echo Who wrote the book Roots?
#read input

if($input == "Alex Haley")
      echo "bla bla"
else
      echo "bla bla bla"
endif

I commented out the method I used to obtain info, the both don't work.

read -p input, gives me:

read [9]: read: no query process

Upvotes: 0

Views: 127

Answers (1)

cdlane
cdlane

Reputation: 41872

echo -n "Enter author: "

set input = "$<"

if ("$input" == "Alex Haley") then
      echo "bla bla"
else
      echo "bla bla bla"
endif

USAGE

> csh test.csh
Enter author: Alex Haley
bla bla
> csh test.csh
Enter author: Mark Twain
bla bla bla
> 

Upvotes: 1

Related Questions