LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.

Notices


Reply
  Search this Thread
Old 09-22-2009, 01:53 PM   #1
jdwilder
Member
 
Registered: Jul 2003
Location: United States
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121

Rep: Reputation: 15
Cygwin issue with bash script


I am trying to run a bash script that was part of a sourceforge svn package I checked out.

It runs fine in Ubunutu Linux. I am trying to install it on my work laptop in Cygwin. The script would die with the error messages:

line 6: $'\r': command not found
line 9: 'for f in $sep_path ; do \r'

I thought this must have been a problem with the difference in line endings, so I ran dos2unix on the file.

Now when I run the file I get the message
' is already registered with AC_CONFIG_FILES.


When I look at other forums for the second problem they say that the file is missing the carriage return '\r'. So this seems to me that I should not have run the dos2unix on the file. But this leaves me with the first problem. When I search forums to fix that problem they all say I did the right thing by using dos2unix; or several other forums said I could run

svn pset svn:eol-style LF *.sh

However this command seems to do nothing. This could be because I was also told I needed to do an svn commit, but since it is not my repository I do not have permission to commit. I also do not see why I would have to commit for the command to have worked.

Does anyone have other ideas of what to do to get rid of the errors so I can run the script? Thank you.
 
Old 09-22-2009, 02:30 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Post the original script before dos2unix, using code tags.

EDIT: and the full error message; what you posted looks like the first line is missing.

Last edited by catkin; 09-22-2009 at 02:32 PM.
 
Old 09-22-2009, 02:56 PM   #3
jdwilder
Member
 
Registered: Jul 2003
Location: United States
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121

Original Poster
Rep: Reputation: 15
I am not how much help the code will be since you cannot see the line endings. The code works fine on my linux machine at home, I just need to use the software at work, so I am trying to get it to install in cygwin.

Here is the code:

Code:
#! /bin/sh
#  author       : Achim Gaedke
#  filename     : ghmm/autogen.sh
#  created      : DATE: April 2001
#  $Id: autogen.sh 1696 2006-09-07 14:49:07Z grunau $

#move GNU m4 to head of PATH
sep_path=`echo $PATH|sed -n 's/:/ /gp'`
for f in $sep_path ; do
  test -f $f/m4 && echo `eval $f/m4 --version 2>/dev/null` |grep GNU >/dev/null && PATH=$f:$PATH
done

#creates ltmain.sh (Call first!!!)
libtoolize --automake --force --copy

#makes aclocal.m4 from acinclude.m4 and other files
aclocal

#scans configure.in and creates config.h.in
autoheader 

#creates Makefile.in from Makefile.am
automake --add-missing --force-missing

#creates configure from configure.in
autoconf
here is the complete error message before dos2unix
Code:
./autogen.sh: line 6: $'\r': command not found
./autogen.sh: line 9: syntax error near unexpected token '$'do\r''
'/autogen.sh: line 9: 'for f in $sep_path ; do
Following this paragraph is the error after dos2unix. It looks like something is missing, and that is because of the incorrect line endings. It's actually a singly-quoted string which ends with an LF (but no CR) causing the closing quote and remainder of the error message to be output on the same line overwriting whatever it actually was that was 'already registered with....':

Code:
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
aclocal-1.11: autom4te failed with exit status: 1
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
autoheader-2.64: '/usr/bin/autom4te-2.64' failed with exit status: 1
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
automake-1.11: autoconf failed with exit status: 1
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
 
Old 09-23-2009, 11:31 AM   #4
judge312
LQ Newbie
 
Registered: Dec 2008
Distribution: fedora,rhel
Posts: 18

Rep: Reputation: 1
Quote:
Originally Posted by jdwilder View Post
I am not how much help the code will be since you cannot see the line endings. The code works fine on my linux machine at home, I just need to use the software at work, so I am trying to get it to install in cygwin.

Here is the code:

Code:
#! /bin/sh
#  author       : Achim Gaedke
#  filename     : ghmm/autogen.sh
#  created      : DATE: April 2001
#  $Id: autogen.sh 1696 2006-09-07 14:49:07Z grunau $

#move GNU m4 to head of PATH
sep_path=`echo $PATH|sed -n 's/:/ /gp'`
for f in $sep_path ; do
  test -f $f/m4 && echo `eval $f/m4 --version 2>/dev/null` |grep GNU >/dev/null && PATH=$f:$PATH
done

#creates ltmain.sh (Call first!!!)
libtoolize --automake --force --copy

#makes aclocal.m4 from acinclude.m4 and other files
aclocal

#scans configure.in and creates config.h.in
autoheader 

#creates Makefile.in from Makefile.am
automake --add-missing --force-missing

#creates configure from configure.in
autoconf
here is the complete error message before dos2unix
Code:
./autogen.sh: line 6: $'\r': command not found
./autogen.sh: line 9: syntax error near unexpected token '$'do\r''
'/autogen.sh: line 9: 'for f in $sep_path ; do
Following this paragraph is the error after dos2unix. It looks like something is missing, and that is because of the incorrect line endings. It's actually a singly-quoted string which ends with an LF (but no CR) causing the closing quote and remainder of the error message to be output on the same line overwriting whatever it actually was that was 'already registered with....':

Code:
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
aclocal-1.11: autom4te failed with exit status: 1
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
autoheader-2.64: '/usr/bin/autom4te-2.64' failed with exit status: 1
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
automake-1.11: autoconf failed with exit status: 1
' is already registered with AC_CONFIG_FILES.
/usr/src/packages/autoconf/26/autoconf2.5-2.64-1/src/autoconf-2.64/lib/autoconf/status.m4:311: AC_CONFIG_FILES is expanded from...
configure.in:316: the top level
autom4te-2.64: /usr/bin/m4 failed with exit status: 1
try unix2dos scriptName "on linux machine "

then run in cygwin

to run agian in linux use, dos2unix.
 
Old 09-23-2009, 01:44 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
I can't see anything in the script that would be upset by dos2unix removing the \r characters.

Perhaps the errors are not caused by the script itself but by the commands it is calling. The error messages suggest it is the m4 command that is borking. You could find out what those m4 commands are by modifying the script
Code:
for f in $sep_path ; do
  test -f $f/m4 && echo $f/m4 --version 2
done
Secondly I don't understand why $PATH is set but not exported. Without the export, it will have no effect on the subsequent commands. You could try
Code:
for f in $sep_path ; do
  test -f $f/m4 && echo `eval $f/m4 --version 2>/dev/null` |grep GNU >/dev/null && PATH=$f:$PATH
done
export PATH
 
Old 09-24-2009, 03:02 PM   #6
jdwilder
Member
 
Registered: Jul 2003
Location: United States
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121

Original Poster
Rep: Reputation: 15
I get the same error when I grab the file off of linux and run it as I do if I have if I run dos2unix. Also, if I edit the code as suggested by catkin I still get the same output, so if the problem is with the m4 command I cannot see any additional information about what that problem would be.

the code I ran was the original code after dos2unix, but I replaced:
test -f $f/m4 && echo `eval $f/m4 --version 2>/dev/null` |grep GNU >/dev/null && PATH=$f:$PATH

with

test -f $f/m4 && echo $f/m4 --version 2
 
Old 09-20-2013, 05:26 AM   #7
dpminusa
LQ Newbie
 
Registered: Mar 2010
Location: USA
Distribution: Gentoo
Posts: 16

Rep: Reputation: 1
Thumbs up Copying a Script to Cygwin from another location

I have had exactly this issue when I copied a file from some other OS to a Folder, then tried to access it with Cygwin. I also had it when I edited a file intended for Cygwin with Wordpad or Notepad. Using d2u was not able to remedy it.

I had to find another way to send it between OS servers. I ultimately found that
  • if I created an email
  • then copied and pasted the script into the body of the email
  • Sent the email to myself on the Cygwin target system
  • then opened a new vim document on the target Cygwin
  • then copied the body of the email to the vim document after using the "o" command

My script was in the correct format and did not encounter the formatting errors any further.

There may be a simpler way but this works for me. I do quite a bit of this.

Last edited by dpminusa; 09-20-2013 at 05:28 AM.
 
Old 09-20-2013, 05:53 AM   #8
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Notepad++ http://notepad-plus-plus.org/
or
Vim for MS-Windows http://www.vim.org/download.php

both can save in appropriate formats, be it 'DOS' or '*nix'
 
  


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
Cygwin and space issue in a script. angel115 Programming 4 05-22-2008 07:43 AM
Bash script debugging issue internetSurfer Programming 4 01-28-2008 08:24 PM
How to run a BASH script in a Batch file (with Cygwin) FaeDine Programming 2 10-27-2007 04:47 PM
[SOLVED] issue with variable in bash script angel115 Programming 4 08-21-2006 01:42 PM
small bash script issue zoomzoom Linux - General 7 06-08-2004 06:33 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 09:15 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
Open Source Consulting | Domain Registration