Simple shell script not working

View: New views
6 Messages — Rating Filter:   Alert me  

Simple shell script not working

by zip184 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is the 2-line shell script I'm trying to run:


#! /bin/sh

touch test.txt


The privledges are set to 777

I get the error output line:  " bash: $'\r': command not found "
for each command I put in the script, including cd, touch, ls, etc.  Echo is the only one that works for some reason.  Anybody have any ideas on how to fix this?

Re: Simple shell script not working

by jreidthompson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, 2007-07-30 at 10:07 -0700, on behalf of zip184 wrote:

> This is the 2-line shell script I'm trying to run:
>
>
> #! /bin/sh
>
> touch test.txt
>
>
> The privledges are set to 777
>
> I get the error output line:  " bash: $'\r': command not found "
> for each command I put in the script, including cd, touch, ls, etc.  Echo is
> the only one that works for some reason.  Anybody have any ideas on how to
> fix this?

$ dos2unix name-of-2-line-script

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Parent Message unknown RE: Simple shell script not working

by Brian McGrew :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What are you using for an editor?  Try it with vi, nedit or emacs.
Sounds like you've got DOS new-line characters on each line.

-brian

Brian D. McGrew        { brian@... ||
brian@... }
--
> Do not read this email while waxing that cat!

-----Original Message-----
From: cygwin-owner@... [mailto:cygwin-owner@...] On Behalf
Of zip184
Sent: Monday, July 30, 2007 10:08 AM
To: cygwin@...
Subject: Simple shell script not working


This is the 2-line shell script I'm trying to run:


#! /bin/sh

touch test.txt


The privledges are set to 777

I get the error output line:  " bash: $'\r': command not found "
for each command I put in the script, including cd, touch, ls, etc.
Echo is
the only one that works for some reason.  Anybody have any ideas on how
to
fix this?
--
View this message in context:
http://www.nabble.com/Simple-shell-script-not-working-tf4171206.html#a11
866789
Sent from the Cygwin Users mailing list archive at Nabble.com.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Simple shell script not working

by Yxg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have also encounted this problem:
"bash: $'\r': command not found"
when start the cygwin programme.Have you found the method to fix it?

RE: Simple shell script not working

by Bengt-Arne Fjellner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yxg wrote:
> I have also encounted this problem:
> "bash: $'\r': command not found"
> when start the cygwin programme.Have you found the method to fix it?

Reason you have edited some file with the wrong editor
run d2u on .bashrc .bash_profile

--
Bengt-Arne Fjellner

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Simple shell script not working

by Morgan Gangwere :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 9/1/07, Bengt-Arne Fjellner
<bengt-arne.fjellner@feed-the-spammers-nao> wrote:

> Yxg wrote:
> > I have also encounted this problem:
> > "bash: $'\r': command not found"
> > when start the cygwin programme.Have you found the method to fix it?
>
> Reason you have edited some file with the wrong editor
> run d2u on .bashrc .bash_profile
>
> --
> Bengt-Arne Fjellner

Also, it looks like you have to run das2unix on the script... " touch
foo.txt\r " is proboably what bash is running.

--
Morgan gangwere

"Space does not reflect society, it expresses it." -- Castells, M.,
Space of Flows, Space of Places: Materials for a Theory of Urbanism in
the Information Age, in The Cybercities Reader, S. Graham, Editor.
2004, Routledge: London. p. 82-93.
-----BEGIN PGP SIGNATURE-----
Version: Gmail/GnuPG Min32 Hack
Comment: Using GnuPG and Gmail - ask me about Grim Fandango

iD8DBQFGV3KQCF9T/dUsmAgRAvESAKDfZYbRtebNO+WPfx6DryIvIwt9TgCgukZG
cIj5nSWws/pAeW2ESlj7GuM=
=Y4uC
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/