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.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
tuturyokgaming
  • 249
  • 1
  • 8
  • 21
  • 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. – Eric Renouf Apr 19 '15 at 13:07
  • I'm invoking the script from a cygwin shell. – tuturyokgaming Apr 19 '15 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? – Eric Renouf Apr 19 '15 at 13:28
  • Show the first few lines of your script including the [shebang line](http://stackoverflow.com/q/2429511/100754). 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. – Sinan Ünür Apr 19 '15 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 03 '15 at 17:55

2 Answers2

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.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
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.