Operating System - HP-UX
1783198 Members
1806 Online
109144 Solutions
New Discussion юеВ

Re: Perl Script execution troubles

 
SOLVED
Go to solution
Lane Frazier
Frequent Advisor

Perl Script execution troubles

Hello all,

A few weeks ago I installed Perl V5.6.0 on my HP-UX 11.0 system. I've downloaded some perl scripts from O'Reilly's web site that go with the book Learning Perl by Tom Christiansen and Randall Schwartz.

The only modification I've made to any of the scripts is on the first line. My perl is located at /opt/perl5/bin

I do not have the location of my scripts in /etc/PATH
I go to the location of the script and type:
./ch01_hello to try and execute it.
When ever I try to execute the script I get execute permission denied.

I have chmod 777 on the file. I have also set chown to root sys.

I'm executing the script logged in as root.

Other scripts that I have typed in work fine. Why would I be getting this message...what am I missing?

Thanks for your time.
Maybe one day I'll understand Openview?!
9 REPLIES 9
John Palmer
Honored Contributor
Solution

Re: Perl Script execution troubles

Does the first line of your script read:-
#!/opt/perl/bin/perl

If you've missed the /perl from the end it will be trying to execute the directory!
Andy Monks
Honored Contributor

Re: Perl Script execution troubles

Does the first line of the script begin :-

#!/opt/perl5/bin/perl

Rick Garland
Honored Contributor

Re: Perl Script execution troubles

Are you running the script as root or as a user?
If a user, are there any system calls thast require root to execute?

Do set the PATH for the perl stuff. Don't need to do it in /etc/PATH, can do it in the .profile and/or the /etc/profile.
John Palmer
Honored Contributor

Re: Perl Script execution troubles

Lane,

I meant /opt/perl5/bin/perl
John Palmer
Honored Contributor

Re: Perl Script execution troubles

Lane,

I meant /opt/perl5/bin/perl
Kofi ARTHIABAH
Honored Contributor

Re: Perl Script execution troubles

Lane:

Check the following:
1. on the first line of your ch01_hello script, set the line:
#!/opt/perl5/bin/perl

2. Make sure that you have /opt/perl5/bin set up in your /etc/PATH (BEFORE) /usr/contrib/bin (otherwise the default perl will take over)

3. finally ensure that your that your perl script actually runs with:
/opt/perl5/bin/perl ./ch01_hello
nothing wrong with me that a few lines of code cannot fix!
Lane Frazier
Frequent Advisor

Re: Perl Script execution troubles

Wow!

talk about some fast answers!

I changed the first line in my script to /opt/perl5/bin/perl and that solved the problem...I did not want to put perl5 in my PATH yet because I was concerned I might "break" something else on my system...

I take it that when the script executes it reads the first line and uses the perl5 code..is that correct?

Thanks again folks for helping the newbie out!
Maybe one day I'll understand Openview?!
Kofi ARTHIABAH
Honored Contributor

Re: Perl Script execution troubles

Lane:

Actually it is highly unlikely that anything will break with perl5 as opposed to the default perl 4 since perl 5 is a superset (and backwardly compatible with perl 4).

Yes, the #! construct is a common scripting construct in unix to tell the command interpreter where to find the the program that executes the rest of the script... you would do the same if you were programming an awk script etc.

Good luck
nothing wrong with me that a few lines of code cannot fix!
Alan Riggs
Honored Contributor

Re: Perl Script execution troubles

I am glad your perl issue is solved. Now, please change the permissions on all of those file to 744 (or 700) immediately. A file owned by root with 777 permissions represents a real security risk, especially as you are likely to be executing these scripts frequently over the next few days.