Cygwin errors


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cygwin errors
# 1  
Old 09-29-2012
Cygwin errors

I'm not sure if this is the right place to post this or should I even be posting this here but here is my problem. I've recently installed Cygwin on my windows laptop so that I can run shell scripts. However I'm getting lots of errors with most lines of code in my scripts although the syntax is correct. I've left a message with the Cygwin mailing list (closest thing to a forum) but I have not received any reply.

I have a very simple script:

Code:
#!/bin/bash
#
 
FRUIT="kiwi"
 
case "$FRUIT" in 
"apple") echo "Apple" ;;
"banana") echo "Banana" ;;
"kiwi") echo "Kiwi" ;;
esac

/usr/bin/debug.sh: line 3: $'\r': command not found
/usr/bin/debug.sh: line 5: $'\r': command not found
/usr/bin/debug.sh: line 6: syntax error near unexpected token 'newline'
/usr/bin/debug.sh: line 6: 'case "$FRUIT" in

The first 2 errors (lines 3 & 5) always occur when there is a blank line. I've no idea why this is a problem.

Please help!
# 2  
Old 09-29-2012
\r is added by your text editor (Windows text editor?) at the end of each line (carriage return)
You have to configure it to NOT write \r at the end of the line.
This User Gave Thanks to tukuyomi For This Post:
# 3  
Old 09-29-2012
Quote:
Originally Posted by tukuyomi
\r is added by your text editor (Windows text editor?) at the end of each line (carriage return)
You have to configure it to NOT write \r at the end of the line.
Thanks for that. How do I configure it to not write \r?
# 4  
Old 09-29-2012
The utility dos2unix converts files with DOS/Windows carriage control to UNIX carriage control. cygwin's unix2dos simply takes a file and converts it without redirecection needed.
Code:
dos2unix myscript.sh
# you should always add execution permissions to a new script
chmod +x myscript.sh

This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 09-29-2012
Quote:
Originally Posted by jim mcnamara
The utility dos2unix converts files with DOS/Windows carriage control to UNIX carriage control. cygwin's unix2dos simply takes a file and converts it without redirecection needed.
Code:
dos2unix myscript.sh
# you should always add execution permissions to a new script
chmod +x myscript.sh

Thanks for that. It's working perfectly now Smilie
# 6  
Old 09-29-2012
Quote:
Originally Posted by millsy5
How do I configure it to not write \r?
The basic notepad.exe (the one provided with windows) is not configurable in this regard. You have to use notepad2, notepad++ or another alternative to do so
# 7  
Old 09-29-2012
Quote:
Originally Posted by tukuyomi
The basic notepad.exe (the one provided with windows) is not configurable in this regard. You have to use notepad2, notepad++ or another alternative to do so
I'm using notepad++. Thanks

I find though that every time I edit the script I have to run the dos2unix again. Is there any way to permanently keep it converted to Unix format?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cygwin Errors: Yaml Configuration issues

Hi everyone! Hope all of you will be fine. I am new to this forum. Well, I am trying to configure yaml-0.1.4 in cygwin on Windows 7. I have written the following command: *******/tmp/yaml-0.1.4 $ ./configure --prefix=/usr && make && make install and the following error appeared. ... (3 Replies)
Discussion started by: imdalucky1
3 Replies

2. Shell Programming and Scripting

opening new instance of cygwin from withing cygwin

I'm using cygwin on win7, What I would like to do is something like this: cygstart cygwin tail -f /foo/test.log | perl -pe 's/error/\e I know I can start a new instance using either of these: mintty -e ... cygstart tail ... But neither of those open in ANSI mode, so I can't do... (0 Replies)
Discussion started by: Validatorian
0 Replies

3. UNIX for Dummies Questions & Answers

Anyone else use Cygwin?

I started to gather some stats from our windows servers through the use of cygwin and sshd :) is anyone else doing this sort of thing? interested in some other indicators I should be checking for... thanks, manny the following is only an example of the type of data I am able to... (4 Replies)
Discussion started by: mr_manny
4 Replies

4. Programming

cygwin

hello ... i am new with cygwin ... and i want you to help me. ... First of all, i want to determine the steady state stream function in a 2-D duct using a square mesh by using the finite-difference methodology and i want to simulate it....and i read a lot of information at... (1 Reply)
Discussion started by: mostafamagdy
1 Replies

5. UNIX for Dummies Questions & Answers

cygwin - sh-3.2$ help!

i am completely new to unix and am trying to learn with cygwin. my problem is simple.... when i use the 'man' command, eg 'man cat' id do not know how to get out of the manual!!!? if i type '!' and Return, rather than having just the $ prompt, it has 'sh-3.2$' as a command prompt.... (1 Reply)
Discussion started by: bobby999
1 Replies

6. UNIX for Dummies Questions & Answers

Major OS errors/Bash errors help!!!!

Hi all, dummy here.... I have major errors on entering the shell. On login I get: -bash: dircolors: command not found -bash: tr: command not found -bash: fgrep: command not found -bash: grep: command not found -bash: grep: command not found -bash: id: command not found -bash: [: =: unary... (12 Replies)
Discussion started by: wcmmlynn
12 Replies

7. AIX

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (2 Replies)
Discussion started by: mcastill66
2 Replies

8. UNIX for Advanced & Expert Users

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (0 Replies)
Discussion started by: mcastill66
0 Replies

9. UNIX for Dummies Questions & Answers

Cygwin

Hi , I have cygwin software on my machine. can i practice shell script on that software or not? thanks sam71 (0 Replies)
Discussion started by: sam71
0 Replies

10. UNIX for Dummies Questions & Answers

about cygwin

hi everyone. i have a problem on installing binary file in my cygwin. could anyone help me wat command should i use to install it ? thanks a lot (4 Replies)
Discussion started by: wins1982
4 Replies
Login or Register to Ask a Question