Operating System - HP-UX
1823066 Members
3093 Online
109645 Solutions
New Discussion юеВ

Perl: Excecute permission deinied

 
SOLVED
Go to solution
Chris Moon_4
New Member

Perl: Excecute permission deinied

Hi all,

On our HPUX 11i, I get an following error when I try to run a perl script, even logged in as root.

# ./test.pl
sh: ./test.pl: Execute permission denied.

This is a very simple script:
# more test.pl
#!/opt/perl/bin
print "hi\n";

I gave 777 permission for this script.
# ll test.pl
-rw-rw-rw- 1 root symix 30 Apr 30 10:51 test.pl

The perl command has following permission:
# ll /opt/perl/bin/perl
-r-xr-xr-x 1 bin bin 1546916 Jun 21 2001 /opt/perl/bin/perl

When I execute perl -v, it runs.

How can I get it around? I would appreciate any suggestion.

Thanks!
11 REPLIES 11
Navin Bhat_2
Trusted Contributor

Re: Perl: Excecute permission deinied

I gave 777 permission for this script.
# ll test.pl
-rw-rw-rw- 1 root symix 30 Apr 30 10:51 test.pl


Should have been -rwxrwxrwx !!
Marvin Strong
Honored Contributor

Re: Perl: Excecute permission deinied

test.pl needs to have x also.

chmod 755 test.pl
or
chmod 777 test.pl
Patrick Wallek
Honored Contributor
Solution

Re: Perl: Excecute permission deinied

If the output of your 'll test.pl' is correct then you do NOT have execute permission for the script.

Do a:

# chmod 750 test.pl

That will give the root user 'rwx' permissions, the group symix 'r-x' permission and no permission to anyone else.

A script MUST hav execute permission to run.

You also need to modify the first line of your script. It should be:

#!/opt/perl/bin/perl

You must have the FULL path, including the file name, to the perl executable.

Do these and your script will work.
Mel Burslan
Honored Contributor

Re: Perl: Excecute permission deinied

your perl script test.pl seems to have 666 permissions instead of 777. This is the main reason why it is refusing to run by itself.

notice the rw-rw-rw- permissions ? you definitely need the "x"s instead of those "-"s

chmod 777 test.pl

hope this helps
________________________________
UNIX because I majored in cryptology...
Mel Burslan
Honored Contributor

Re: Perl: Excecute permission deinied

also the first line of your script should point to the perl executable not to the directory it is contained in, i.e.,

#!/opt/perl/bin/perl

________________________________
UNIX because I majored in cryptology...
Chris Moon_4
New Member

Re: Perl: Excecute permission deinied

I just wrote this test script and forgot to set the permission. Anyway, it still doesn't run with 777 permission.

# ll test.pl
-rwxrwxrwx 1 root symix 30 Apr 30 10:51 test.pl
# ./test.pl
sh: ./test.pl: Execute permission denied.
Navin Bhat_2
Trusted Contributor

Re: Perl: Excecute permission deinied

Have the perl excutable path in the first line.
Patrick Wallek
Honored Contributor

Re: Perl: Excecute permission deinied

#!/opt/perl/bin/perl

MUST be the firstline of your script. You only have /opt/perl/bin you don't specify what file in that directory to use. You MUST put the file name as well.
Marvin Strong
Honored Contributor

Re: Perl: Excecute permission deinied

as the others stated,

#!/opt/perl/bin

should be

#!/opt/perl/bin/perl

Chris Moon_4
New Member

Re: Perl: Excecute permission deinied

That was it! The first line has to point to the executable file, not only the directory. Almost everyone pointed to the right direction. Thank you very much for your quick response and help.

I used this forum for the first time and I never expected to receive so much help and can solve the problem in just few minutes. Very impresssive! Thanks everyone!
Navin Bhat_2
Trusted Contributor

Re: Perl: Excecute permission deinied

Would be good to give points to your friends.