in reply to (8)Exec format error: when running the script on Linux

I came across this thread when Googling on "(8)Exec format error:". This probably not the answer to the question asked... However, I've just had this problem and it turned out that I'd started my script with a newline and not #!/usr/bin/perl (ie I'd opened emacs hit return, then paged down to the bit of code I was working on).

so the script worked as 'perl foo.pl' but not via apache

Hope this helps someone.

  • Comment on Re: (8)Exec format error: when running the script on Linux

Replies are listed 'Best First'.
Re^2: (8)Exec format error: when running the script on Linux
by Anonymous Monk on Apr 22, 2009 at 19:31 UTC
    I had the same issue, Thank You for the wisdom to solve my issue in such a timely manner. May happiness find you on your travels.
Re^2: (8)Exec format error: when running the script on Linux
by Anonymous Monk on Jun 30, 2009 at 11:35 UTC
    solved my problem too. thank you very much!
Re^2: (8)Exec format error: when running the script on Linux
by Anonymous Monk on Jun 30, 2009 at 11:50 UTC
    That is good reason to adopt template
    #!/usr/bin/perl -- #!/usr/bin/perl -w -- #!/usr/bin/perl -Tw -- ...
    -- signals end of options
Re^2: (8)Exec format error: when running the script on Linux
by Hermano23 (Beadle) on Jul 29, 2014 at 15:50 UTC
    You are a wonderful person for taking the time to do this. Thank you.
Re^2: (8)Exec format error: when running an unicode script
by Anonymous Monk on Oct 15, 2011 at 21:04 UTC

    I tried what you monks said, but it didn't quite work out for me.
    Until I discovered that some stupid editor inserted the utf-8 byte order mark without asking and thus mangled my shebang into #!/usr/bin/perl

    I had to change the encoding to remove the mark, and now everything works fine :)

      If you are using Notepad++ as your editor and you are using unicode, be sure to have it set to "Encode n UTF-8 without BOM".

      Otherwise, you get that leading character,