1

Hello I'm trying to run a perl script on a Windows 64 bit. I'm getting the error like this :

/usr/bin/perl : bad interpreter : Permission denied

I have my perl script on my windows 64 bit C:\test\perlscripts\testperl.pl.

5
  • Are you invoking the script from a cygwin shell or a windows shell? If you're trying to run it from Windows (either a cmd shell or double clicking on it in Explorer) you won't be able to use Cygwin paths/interpreters. Apr 19, 2015 at 13:07
  • I'm invoking the script from a cygwin shell. Apr 19, 2015 at 13:13
  • 2
    Did you create the file using a Windows editor? If so there could be a stray \r at the end of the line so the real interpreter it's trying to invoke is /usr/bin/perl^M? From the shell can you run /usr/bin/perl and have it actually execute perl? Apr 19, 2015 at 13:28
  • Show the first few lines of your script including the shebang line. Also include the hexdump of the first few lines: From the Cygwin bash shell: head testperl.pl | od ... I am guessing you have an extrac CR following the perl on the shebang line. Apr 19, 2015 at 14:53
  • i had similar problem but issue was not related . putting it in comment so that it may help somebody. In case you are not using C drive for the executable cygwin will never be able to find the same. Keep all the program in C drive for cygwin to work on
    – R-JANA
    Sep 3, 2015 at 17:55

2 Answers 2

3

You probably saved the Perl script with DOS style line endings. The shell is looking for a file called /usr/bin/perl<CR>.

Save your files with Unix-style line endings. My .vimrc which I use with my natively compiled vim and gvim has:

set fileformat=unix
set fileformats=unix,dos

Check your editor's settings for the appropriate options.

To fix line endings in a particular file, use $ dos2unix filename.

2

You may not install Perl in default cygwin64 package. Please ensure that you have Perl at /usr/bin/perl.exe.

If it is not there, run setup-x86_64.exe again and select Perl interpreter.

1
  • This worked for me when the error quoted by the OP arose trying to use autoreconf in cygwin. Dec 15, 2017 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.