Find the answer to your Linux question:
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 ...
  1. #1
    Just 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.


  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    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

  3. #3
    Just 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.

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    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 )

  5. #5
    Just 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

  6. #6
    Just Joined!
    Join Date
    Jun 2007
    Posts
    5
    worked for me too! thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...