Results 1 to 6 of 6
Hi, I am a linux newbee, using fedora core 5.
I get the following message when I try to run a simple test script. The same script runs on another ...
- 07-13-2006 #1Just Joined!
- Join Date
- Jul 2006
- Posts
- 3
bad interpreter: No such file or directory
Hi, I am a linux newbee, using fedora core 5.
I get the following message when I try to run a simple test script. The same script runs on another machine very similar to my own.
./mydate: /bin/bash^M: bad interpreter: No such file or directory
The file does has execute rights.
- 07-13-2006 #2
I take it that you wrote the script on a Windows machine? And ran it under Cygwin, I suppose?
In Windows, the end of a line is CRLF (Carriage-Return, Line-Feed). In Unix-like systems, it is just LF. So when you try to run that script, every line has an extra CR on the end.
The way to fix this is to use some sort of utility to fix that. You might use the utility dos2unix if you have it installed, or just go download it.
Alternatively, the following script should work:
Code:#!/usr/bin/perl die "Usage: $0 < files >\n" unless @ARGV; for $file (@ARGV) { open IN, $file or die "$0: Cannot open $file for input!\n"; my @lines = <IN>; close IN; open OUT, "> $file" or die "$0: Cannot open $file for output!\n"; s/\r$// for @lines; print OUT for @lines; }DISTRO=Arch
Registered Linux User #388732
- 07-13-2006 #3Just Joined!
- Join Date
- Jul 2006
- Posts
- 3
Hi Cabhan,
Thanks for replying but I am running pure Fedora core 5, the script was written in Fedora so there is no CRLF incompatability here.
- 07-13-2006 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi, IrateRover.
My first thought was the same as Cabhan's, so I tried adding a ^M after the bash in the shebang (first line: #!/bin/bash^M ) and did get an error message, but it was Command not found.
Googling for "bad interpreter linux" produced a number of hits and our friends in NZ provided a number of possible causes on their wiki. Best wishes ... cheers, drl
http://www.wlug.org.nz/CommonErrors
( edit 1, 2: typos )Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 07-30-2006 #5Just Joined!
- Join Date
- Jul 2006
- Posts
- 3
bad interpreter: No such file or directory
Hi Cabhan, I tried out your script against my test script and now it works.
many thanks
IrateRover
- 02-24-2010 #6Just Joined!
- Join Date
- Jun 2007
- Posts
- 5
worked for me too! thanks!


