LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-19-2007, 05:15 AM   #16
sadashiv.linux
LQ Newbie
 
Registered: May 2005
Posts: 13

Rep: Reputation: 1

bad interpreter: No such file or directory

I also got above error; so I was looking going through this topic.
Just to add -- this error also comes when no perl is installed on your system.
While trying command "perl -i -pe's/\r$//;' <file name here>" I come to know about this Thanks!!!

Sadashiv
 
Old 02-25-2008, 11:09 PM   #17
cnschulz
LQ Newbie
 
Registered: Dec 2007
Posts: 4

Rep: Reputation: 0
Smile

Quote:
Originally Posted by mahantesh_hongal View Post
Dear wbrummet. Thanks a billion.

Your simple perl command (perl -i -pe's/\r$//;' <file name here>) clears up my issue

Thanks,
Mahantesh Hongal

thanks, your cr/lf suggestion is still helping people!



c.
 
Old 04-22-2008, 02:17 AM   #18
deepdash
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
Thanks XunXu and wbrummet!

Both these worked -

dos2unix <filename>

perl -i -pe's/\r$//;' <filename>
 
Old 04-24-2008, 05:16 PM   #19
tieuphongvan
LQ Newbie
 
Registered: Apr 2008
Posts: 14

Rep: Reputation: 0
Talking

Either using the perl command:

Code:
perl -i -pe's/\r$//;' <file name here>
or trying to ftp the script from a Windows-based machine to a Unix-based machine while NOT under binary mode will do the job

Thanks to both wbrummet and timmeke!
 
Old 06-16-2008, 05:06 PM   #20
peterlombardo
LQ Newbie
 
Registered: Nov 2006
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by tieuphongvan View Post
Either using the perl command:

Code:
perl -i -pe's/\r$//;' <file name here>
or trying to ftp the script from a Windows-based machine to a Unix-based machine while NOT under binary mode will do the job

Thanks to both wbrummet and timmeke!
I had this issue which drove me nuts. I was familiar with dos2unix and the variations of line feeds...but still nothing fixed it and it still didn't execute.

As it turns out, the script I was trying to execute was on a external USB drive mounted with the 'noexec' option. doh! Move the script to local hard drive (mounted without 'noexec' obviously) and everything works...

Regards,
Peter
 
Old 11-14-2008, 03:16 PM   #21
gaurav.s.agrawal
LQ Newbie
 
Registered: Nov 2008
Posts: 5

Rep: Reputation: 0
I was facing the same problem and converting from dos to the uniz format did the trick
 
Old 01-15-2009, 09:11 AM   #22
Samurai Unix
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by wbrummet View Post
I have run into this problem many times when editing scripts on a windows based system then FTP'ing them onto my servers. I simple Perl command always seems to clear up the problem. Try the following command on your text file then try and run it.

perl -i -pe's/\r$//;' <file name here>
Thanks. This script worked for me as well. What does it do?
 
Old 03-19-2009, 09:47 AM   #23
irwinr
LQ Newbie
 
Registered: Dec 2004
Location: Texas
Distribution: Fedora Core 6, CentOS 4.4, CentOS 5
Posts: 14

Rep: Reputation: 0
Quote:
Originally Posted by timmeke View Post
A lot of the commands (using tr, perl, ...) posted here all do pretty much the same as the "dos2unix" utility mentioned. Please use this utility, as it was specifically created for this CR\LF issue.
Yes, dos2unix may be preferred, but it's not always installed. I ran into this issue today with a server that did not have a dos2unix command but did have perl installed, so the perl one liner here saved me a bit of time.

We should encourage alternative solutions, not discourage them.

-Jeremy
 
Old 03-19-2009, 11:10 AM   #24
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by Samurai Unix View Post
Thanks. This script worked for me as well. What does it do?
It changes line endings from windows to unix format.

Quote:
Originally Posted by irwinr View Post
We should encourage alternative solutions, not discourage them.

-Jeremy
The thread is dead. First message is from 2004.
 
Old 03-19-2009, 11:22 AM   #25
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,634

Rep: Reputation: Disabled
Quote:
Originally Posted by ErV View Post
...The thread is dead...
It's not, since you just posted .
 
Old 03-20-2009, 12:16 PM   #26
tieuphongvan
LQ Newbie
 
Registered: Apr 2008
Posts: 14

Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by JZL240I-U View Post
It's not, since you just posted .
It took 1 yr for a good solution, and there are still people looking for the same solution after 5 yrs....Long live thread, woot
 
Old 04-01-2009, 05:01 PM   #27
manishsingh4u
Member
 
Registered: Oct 2005
Location: Bhopal, India
Distribution: RHEL 6
Posts: 422

Rep: Reputation: 30
Smile Thanks

This worked great.
Code:
perl -i -pe's/\r$//;' <file name here>
Thanks.

Manish
 
Old 04-03-2009, 07:42 PM   #28
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
I'd be surprised if dos2unix is not part of the std install these days..
 
Old 03-30-2010, 06:51 AM   #29
mwdmarco
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
I had the same problem as everybody who has been asking here.
I tried some of the suggested ideas but still no success
The way I have fixed it is by removing the top line

#!/bin/bash

once I removed that, is working very well

Hope this helps

Marco
 
Old 11-11-2010, 11:50 AM   #30
theRiley
LQ Newbie
 
Registered: Nov 2010
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by nx5000 View Post
Put this in .vimrc

" Add keymappings
map <F4> :set fileformat=unix<CR>
map <F5> :set fileformat=dos<CR>

Then use F4/F5 for changing fileformat

thanks, this gets to the heart of the problem, and provides a solution.

coming from the unix side, hadnt realized that linux vi defaulted (at least in my RHEL distro) to dos crlf behavior.

which is bad imo, since it breaks intrinsic functionality.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"bad interpreter : no such file or directory" when configure "flex" acer_peri Linux - Software 10 11-10-2010 01:19 AM
: bad interpreter: No such file or directory ciberrust Linux - Networking 10 09-09-2010 06:51 AM
: bad interpreter: No such file or directory lnx8 Linux - General 4 04-29-2004 02:56 AM
bash: ./fam_mirror: bad interpreter: No such file or directory linuxboy69 Linux - Software 5 12-22-2003 11:35 AM
bash: ./myscript: bad interpreter: No such file or directory Stefangeelen Linux - Newbie 3 09-05-2002 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:58 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