Other *NIXThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121
Rep:
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.
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121
Original Poster
Rep:
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
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
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
Distribution: Fedora Core 7 and older, Knoppix, Ubuntu
Posts: 121
Original Poster
Rep:
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.