LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   unexpectedksh:----Error received (https://www.linuxquestions.org/questions/linux-newbie-8/unexpectedksh-error-received-936752/)

jimblim 03-27-2012 03:48 PM

unexpectedksh:----Error received
 
I am new to Linux. We have a server that is used primarily for ssh but would like to add running some ksh scripts. I am running one but am getting this error: ' unexpectedksh: line 87: syntax error at line 90: `in



line 87=ARS_OPTS=$@
line 90=case "$1" in

THIS IS THE CODE:


ARS_OPTS=$@
while [ $# -gt 0 ]
do
case "$1" in
-h|-\?) #display help info and exit
Usage;;
-s) #severity
SEVERITY=$2; shift; shift;;
-g) #assignment group
GROUP=$2; shift; shift;;
-d) #description
DESC=$2; shift; shift;;
-c) #config file
ARS_CONFIGFILE=$2; shift; shift;;
-*) #invalid options - show error and exit
echo "Invalid option: $1 use -h for help"; exit 1;;
*) #notes (stick everything else in notes)
ARS_NOTES="$ARS_NOTES $1"; shift;;
esac
done


Any ideas?

chrism01 03-27-2012 05:59 PM

Difficult to tell from that; try putting
Code:

set -xv
as the 2nd line of your code (ie after the #!/bin/ksh line).
This shows what the parser is doing ie the 'before' & 'after' parsing of each line; very good for debugging.
Also, next time, please use code tags when posting https://www.linuxquestions.org/quest...do=bbcode#code to preserve formatting & makes it easier to read.

pan64 03-28-2012 01:28 AM

usually you have something mistyped before line 87....

jimblim 03-29-2012 03:29 PM

Thanks for your help! I did a od on the file. It contained \r\n...Removed the \r...Works now..

chrism01 03-29-2012 06:22 PM

If you did that manually, you may like to know about this http://linux.die.net/man/1/dos2unix; very handy when there's a lot to fix and/or you want to automate it.


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