Error in code
3
0
Entering edit mode
9.9 years ago
Alpha ▴ 30

Can anyone please help me with this code? It gives me below error in linux shell

EDIT: Added full code

./HapView_LDBlock.sh: line 27: syntax error: unexpected end of file
#--------------------------------------------------------------------
#Copyright (c) <2006>, <Chun Zhang and Affymetrix INC.>
#All rights reserved.
#This is OSI certified open source software and is distributed 
#under the BSD license.For details please refer to license.txt. 
#------------------------------------------------------
#This script is written by Dr. Chun Zhang
#For calculating LD using 4GAM test
#------------------------------------------------------
count=0
chrnum=14
haphead="HapView_Chr"
hapinfo=".info"
happed=".ped"
while [ $count -lt $chrnum ]
do
    count=`expr $count + 1`
    subcount=0
    tmpped=$haphead$count$happed
    tmpinfo=$haphead$count$hapinfo
    echo $tmpped
    echo $tmpinfo
    if [ -e $tmpped ] 
    then
            java -jar Haploview.jar -nogui -pedfile $tmpped -info $tmpinfo -dprime -blockoutput GAM 
    fi
    done

Thank you in advance!

bash software-error genome • 2.8k views
ADD COMMENT
3
Entering edit mode

Your code only contains 18~20 lines. So maybe this is not the full file?

ADD REPLY
0
Entering edit mode

I didn't include all of the comments lines, so...Here is the complete code that was in the file

#--------------------------------------------------------------------

#Copyright (c) <2006>, <Chun Zhang and Affymetrix INC.>
#All rights reserved.
#This is OSI certified open source software and is distributed 
#under the BSD license.For details please refer to license.txt. 
#------------------------------------------------------
#This script is written by Dr. Chun Zhang
#For calculating LD using 4GAM test
#------------------------------------------------------
count=0
chrnum=14
haphead="HapView_Chr"
hapinfo=".info"
happed=".ped"
while [ $count -lt $chrnum ]
do
    count=`expr $count + 1`
    subcount=0
    tmpped=$haphead$count$happed
    tmpinfo=$haphead$count$hapinfo
    echo $tmpped
    echo $tmpinfo
    if [ -e $tmpped ] 
    then
            java -jar Haploview.jar -nogui -pedfile $tmpped -info $tmpinfo -dprime -blockoutput GAM 
    fi
    done

Thank you!

ADD REPLY
3
Entering edit mode
9.9 years ago
Siva ★ 1.9k

It seems to me the problem is the ^M (CTRL-M) character at the end of each line. This script was probably written in a text editor in Windows OS and you are trying to run it in Linux. Try to remove those ^M characters and run the script. There are several ways to remove the ^M character.

ADD COMMENT
0
Entering edit mode

Hi. Can you helping me in removing ^M? I don't see that letters when I open code in jEdit.

ADD REPLY
1
Entering edit mode

The easiest way is to use "dos2unix" command

dos2unix HapView_LDBlock.sh

Check again to make sure they are gone

cat -v HapView_LDBlock.sh
ADD REPLY
0
Entering edit mode

I did it using "sed" command. It worked.....

ADD REPLY
0
Entering edit mode

Great. Thanks to Ram for suggesting to display the non-printing characters in the file (cat -te).

ADD REPLY
0
Entering edit mode

It's a simple matter of changing line endings. Check this out: http://www.jedit.org/users-guide/line-separators.html

ADD REPLY
4
Entering edit mode
9.9 years ago
Ram 44k

Could you give us the output of cat -te ./HapView_LDBlock.sh please?

ADD COMMENT
0
Entering edit mode
pinku@ram:~/Documents$ ./HapView_LDBlock.sh 
./HapView_LDBlock.sh: line 31: syntax error: unexpected end of file
pinku@ram:~/Documents$ cat -te ./HapView_LDBlock.sh
#--------------------------------------------------------------------^M$
#Copyright (c) <2006>, <Chun Zhang and Affymetrix INC.>^M$
#All rights reserved.^M$
#This is OSI certified open source software and is distributed ^M$
#under the BSD license.For details please refer to license.txt. ^M$
#------------------------------------------------------^M$
#This script is written by Dr. Chun Zhang^M$
#For calculating LD using 4GAM test^M$
#------------------------------------------------------^M$
count=0^M$
chrnum=14^M$
haphead="HapView_Chr"^M$
hapinfo=".info"^M$
happed=".ped"^M$
while [ $count -lt $chrnum ]^M$
do^M$
^Icount=`expr $count + 1`^M$
^Isubcount=0^M$
^Itmpped=$haphead$count$happed^M$
^Itmpinfo=$haphead$count$hapinfo^M$
^Iecho $tmpped^M$
^Iecho $tmpinfo^M$
^Iif [ -e $tmpped ] ^M$
^Ithen^M$
^I^I    java -jar Haploview.jar -nogui -pedfile $tmpped -info $tmpinfo -dprime -blockoutput GAM ^M$
^Ifi^M$
^Idone^M$

Thank you so much for helping me out on this!

ADD REPLY
1
Entering edit mode
^Iif [ -e $tmpped ] ^M$
^Ithen^M$
^I^I    java -jar Haploview.jar -nogui -pedfile $tmpped -info $tmpinfo -dprime -blockoutput GAM ^M$
^Ifi^M$
^Ithen^M$
^Idone^M$

You seem to have a then in the line before your done. Try removing that.

ADD REPLY
0
Entering edit mode

I didn't work again!

ADD REPLY
0
Entering edit mode

Quick question: Why does the code you pasted for Sam here not correspond to the cat -te output or the code pasted in the question? Please double check your code and give us the exact code you are using.

Also, before the cat -te, your execution points to an error in a non-existent line 31. I'd appreciate it if you could share the file directly with us, using DropBox or some such service. Or let me know if you'd be more comfortable emailing the file to me.

ADD REPLY
2
Entering edit mode
9.9 years ago
Debug error: There is no 27th line in the given code.
ADD COMMENT
0
Entering edit mode

I don't see lines after "done" in the code file, however, the shell expecting 'then' after 'done' and I'm not sure what to be included in there....

ADD REPLY

Login before adding your answer.

Traffic: 1252 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6