Score:1

perl script wont run unless I use perl prefix

cn flag

I have a weird problem trying to run a simple perl script on ubuntu 22.04.

test.pl content:

#!/usr/bin/perl
print "Hello\n";

output of which perl command:

/usr/bin/perl

I used to run scripts with just their path, but now I get permission denied when doing so, unless I use the perl prefix.

distcc@a172-24-178-137:~$ ./test.pl
bash: ./test.pl: Permission denied
distcc@a172-24-178-137:~$ perl ./test.pl
Hello

Permissions look fine to me:

distcc@a172-24-178-137:~$ ls -l test.pl
-rwxr-xr-x 1 distcc staff 33 Feb  6 17:07 test.pl

what is causing the problem?

DrHyde avatar
im flag
I wonder if an invisible character has snuck into the shebang line. Can you show us the output from `hexdump -C test.pl` please.
Kyle avatar
py flag
The size of the file (33 bytes) matches the clean version I made locally. There's no invisible character. That error looks like this: `bash: ./test.pl: /usr/bin/perl^M: bad interpreter: No such file or directory`
Kyle avatar
py flag
A related post from the sidebar seems to have the answer. Perhaps [the filesystem is mounted with 'noexec'](https://askubuntu.com/questions/1346733/bash-script-permission-denied-when-tying-to-run).
guygrinberger avatar
cn flag
@Kyle you are right, that was the case. a bit different on 22.04 but same root cause.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.