Link to home
Start Free TrialLog in
Avatar of ttrogden
ttrogden

asked on

Perl/cgi problem

I'm having a problem with my new Linux Install.  When i try to run a cgi or .pl file i get bad command - but when i type /usr/bin/perl file namke it works - i've got #!/usr/bin/perl at the top of my script - do i need to do something else ??  - I've granted the correct rights - i'm thinking i need to add something to the perl engine or something
Avatar of HalldorG
HalldorG
Flag of Iceland image

and you have chmod the files to

755?

and you are running them with full path
or

../myscript.pl

 
Avatar of ttrogden
ttrogden

ASKER

yes - i know the permissions are right cause when i type in /usr/bin/perl <filename.pl> it works - it's just when i try to run the script <filename.pl> that it doesn't work.  Am I suppose to setup something in Apache to look for cgi/.pl scripts????


tommyt
Apache doesn't come in to play when you run a Perl script from the command-line (unless the script is calling it of course).  When you are in the directory that contains the script, try

../filename.pl

Who is the script owned by?  Who does httpd run as?  What are the permissions on all the directories down to the one with the script?

try su'ing to the apache user, and running the script using the full path to the script...
I thought HalldorG had typed two periods, but I see experts-exchange (!) replaced my one period with two as well.  It should be

single period/filename.pl
a script doesn't need to be executable to be run using:

/usr/bin/perl script.pl

as you are only passing the script as an argument to the executable 'perl'.

What has apache got to do with this, are you trying to set up a cgi perl script - if you are you need to set up cgi in the httpd.conf and the access.conf.

Finally, make sure your script is in you r PATH var or it won't execute unless you type in a full or relatice path to it.
i found that it's easier to tell apache to run as a specific user that you create and then make that user the owner of the scripts
'bad command'?  What's the exact error message?
ASKER CERTIFIED SOLUTION
Avatar of lafor021199
lafor021199

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial