LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-18-2016, 01:05 AM   #1
BunnyDoubts
LQ Newbie
 
Registered: Mar 2016
Posts: 1

Rep: Reputation: Disabled
Unhappy I am getting the error that "else:endif not found" when i gave 1 as input to following script. Please help me to get rid of this


#!/bin/csh

echo -n "Enter Input :"
set answ = $<

if($answ == 1)then
echo Awsome
echo Worst
else echo $answ
endif



the output is


[infa@bosdwetltst scripts]$ ./abc.sh
Enter Input :1
Awsome
Worst
else: endif not found.

Last edited by BunnyDoubts; 03-18-2016 at 01:08 AM. Reason: Adding the error output
 
Old 03-18-2016, 01:53 AM   #2
153rd
Member
 
Registered: Mar 2015
Location: The Netherlands
Distribution: CentOS 7, Ubuntu 12.04, Linux-Mint 17.3
Posts: 46

Rep: Reputation: Disabled
If I'm not mistaken you close the 'if' with a 'fi'. Not sure, I don't write bash scripts, but I saw it come along on numerous occasions when snooping around.
 
Old 03-18-2016, 02:03 AM   #3
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Hello,

153rd, I agree with you that in bash (Bourne Again Shell), we close the 'if' block with 'fi'. But in csh (C Shell), we close it with 'endif' (http://tldp.org/LDP/Bash-Beginners-G...tml/x7369.html).

As for the above code, it looks right. Might be a small syntax mistake. Try to change echo $answ to echo "$answ" like in this http://www.csee.wvu.edu/~hayhurst/cs604/scripts.htm
 
Old 03-18-2016, 02:36 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
Please use [code][/code] tags when showing code / data.

I haven't looked at csh in forever, but I think you cannot have something on the same line as the else.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Require help with iptables script and "command not found" error FireandIce Linux - Security 3 11-16-2015 08:48 AM
[SOLVED] X: "loading extension glx" "no screens found" "fatal server error" (w/ nvidia driver) Geremia Slackware 7 12-29-2014 11:00 AM
"Command not found" error using expr in shell script Harish sharma Linux - Newbie 17 11-08-2012 05:53 AM
automount 5.0.3 with auto.smb script yields "key "<name>" not found in map" rbergen Linux - Software 0 01-01-2010 12:27 PM
"failed to execute child process" "Input/output error" fl.bratu Fedora 4 12-15-2008 04:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration