LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-27-2013, 09:11 AM   #1
barny_be
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Rep: Reputation: Disabled
Post Parse error when using case statement


Hi,
I cannot understand what is going on here. What am I doing wrong?

#!/bin/ksh
echo "type a number"
read whatisit
case $whatisit in
8) echo "Correct";;
*) echo "No, wrong";;
esac
exit

./script:4: parse error near `in^M'
 
Old 09-27-2013, 09:19 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
The ^M points to a windows file/entry. Not sure which editor you use to write these scripts, but make sure they are written as a normal file.

You can use the dos2unix command to fix your current script:
Code:
dos2unix script_name
 
1 members found this post helpful.
Old 09-27-2013, 09:25 AM   #3
barny_be
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thumbs up That fixed it

Great thanks, there was an invisible windows carriage return.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Perl switch statement throwing error like Bad case statement (invalid case value?) kavil Programming 2 10-07-2010 05:50 AM
PHP Error Parse error: parse error, unexpected $ in /home/content/S/k/i/SkinCare4U/h CowanServices Programming 2 12-09-2008 09:26 PM
Case Statement craigjward Programming 6 12-13-2007 12:33 AM
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 09:05 PM
Parse error: parse error, unexpected $ in /home/content/d/o/m/domain/html/addpuppy2.p Scooby-Doo Programming 3 10-25-2007 10:41 AM


All times are GMT -5. The time now is 03:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration