Piotr Bielski Piotr Bielski - 5 months ago 83
Perl Question

Running Perl executables in git-bash

I tried to run script in git bash command line and I saw:

"use: command not found"

When I changed sh file from
'./clean_translations.pl'
to '
perl ./clean_translations.pl'

After that script works.

I have win 8.1. Path is as in other PC (win 7).
What should I change to works without 'perl'?

Edit: echo $PATH:

/c/Users/PBI/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/PBI/bin:/c/usr/bin:/c/strawberry/c/bin:/c/strawberry/perl/bin:/c/straw
berry/perl/site/bin:/c/strawberry/c/lib:/c/strawberry/perl/site/lib:/c/strawberr
y/perl/lib:/c/Program Files (x86)/ActiveState Komodo IDE 8:/c/instantclient_12_1
:/c/Program Files/Java/jdk1.8.0_91/bin:/c/Program Files/Java/jre1.8.0_91/bin:/c/
Program Files (x86)/Intel/iCLS Client:/c/Program Files/Intel/iCLS Client:/c/Wind
ows/system32:/cmd:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/Window
sPowerShell/v1.0:/c/Program Files/Intel/Intel(R) Management Engine Components/DA
L:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Prog
ram Files/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)
/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)/ATI Tech
nologies/ATI.ACE/Core-Static:/c/Program Files (x86)/GitExtensions:/bin:/mingw64/
bin:/usr/bin/vendor_perl:/usr/bin/core_perl

Answer

You need to use a shebang.

Add this as the first line of the script:

#!/usr/bin/env perl

This conveys that the script should be run using Perl interpreter.

If you are running the script on windows shebang is not parsed. The file extension(.pl) is used to decide the interpreter. In a bash shell shebang is necessary.

Comments