Cygwin Syntax Error R
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow syntax error near unexpected token r in shell script the company Business Learn more about hiring developers or posting ads with us Stack Overflow unexpected token r bash Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 cygwin dos2unix million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up '\r': command not found - .bashrc / .bash_profile up vote 94 down vote favorite 30 I have windows, using $' r' command not found shell script Cgywin, trying to set JAVA_HOME permanently through my .bashrc file. .bashrc: export PATH="$JAVA_HOME/bin:$PATH" export JAVA_HOME=$JAVA_HOME:"/cygdrive/c/Program Files (x86)/Java/jdk1.7.0_05" .bash_profile: if [ -f ~/.bashrc ]; then source ~/.bashrc fi running cygwin: -bash: $'\377\376if': command not found -bash: $'then\r': command not found : No such file or directorysu//.bashrc -bash: /cygdrive/c/Users/jhsu//.bash_profile: line 3: syntax error near unexpected token `fi' -bash: /cygdrive/c/Users/jhsu//.bash_profile: line 3: `fi' I am not sure if I took the commands from a tutorial
Shell Script Syntax Error Near Unexpected Token $'do R''
that was meant for another system or if I am missing a step. Or whitespace is causing my commands not to run properly. I've looked at multiple similar questions but I haven't found one where the question has my error exactly. Thanks EDIT #1: my home path $ echo $HOME /cygdrive/c/Users/jhsu So I believe the files should be placed in the correct spot. EDIT #2: echo ~ $ echo ~ /cygdrive/c/Users/jhsu/ bash shell cygwin newline share|improve this question edited May 12 '15 at 21:49 Charles Duffy 94.9k15102142 asked Jul 23 '12 at 16:45 Jasmine 7841615 What does echo ~ give? –harpo Jul 23 '12 at 16:52 $ echo ~ /cygdrive/c/Users/jhsu/ –Jasmine Jul 23 '12 at 17:04 possible duplicate of running bash script in cygwin on windows 7 –Qix Apr 24 '14 at 19:53 The issue is not specific to cygwin -- the same problem can happen if creating a script on a DOS machine and doing a binary transfer to a Linux system and running it there; I've removed the cygwin reference from the title so folks having this issue in other circumstances will be more likely to take the question (and its non-Cygwin-specific answers) seriously. –Charles Duffy May 12 '15 at 21:49 add a comment| 12 Answer
error message while running a script? From: "Larry Hall (Cygwin)"
Syntax Error Near Unexpected Token Do In Shell Script
running a script? References:
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags Users http://unix.stackexchange.com/questions/81355/trouble-with-read-line-script-in-cygwin Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Trouble with read line script in Cygwin up vote 1 down vote favorite I'm on windows 7 using Cygwin. My script and text file are located in the same directory. #!/bin/bash while read name; do echo syntax error "Name read from file - $name" done < /home/Matt/servers.txt I get this error and I don't know why because this is correct while loop syntax..? u0146121@U0146121-TPD-A ~/Matt $ ./script.sh ./script.sh: line 4: syntax error near unexpected token `done' ./script.sh: line 4: `done < /home/Matt/servers.txt' Can anybody tell me what I'm doing wrong? I think its because I'm on windows and using Cygwin. bash shell-script cygwin share|improve this question edited Jul 1 '13 at 21:59 Gilles 370k676711120 asked Jul 1 '13 at 15:40 mkrouse 1891616 It should work. can you check complete syntax error near path of your home from cygwin prompt by going to /home/Matt/. please note that your home would be under C:\cygwin\home\matt. It is case sensitive when you access from cygwin. –Raza Jul 1 '13 at 16:03 2 You have CR-LF line ending in the script. Change it to LF only (edit with vim, :set notextmode :wq) and all works. –ott-- Jul 1 '13 at 16:05 @ott--I'm not quite sure what you mean. –mkrouse Jul 1 '13 at 16:07 @Salton Not sure what you are asking either. –mkrouse Jul 1 '13 at 16:09 You can also try flip -u script.sh to remove CR LF –Raza Jul 1 '13 at 16:15 | show 1 more comment 4 Answers 4 active oldest votes up vote 1 down vote accepted As pointed out by ott--, your script has CR LF line endings. This is more visible with od. $ od -c script 0000000 # ! / b i n / b a s h \r \n w h i 0000020 l e r e a d n a m e ; d o 0000040 \r \n e c h o " N a m e r e a 0000060 d f r o m f i l e - $ n 0000100 a m e " \r \n d o n e < / h o 0000120 m e / M a t t / s e r v e r s . 0000140 t x t \r \n 0000145 As you can see, you have \r (carriage return) and \n (line feed) characters at the end of each line where you should only have \n c