It is currently Tue, 17 May 2022 02:24:20 GMT



 
Author Message
 running perl script on linux
I recently installed linux (Red Hat 6.1) on my PC an would like
to run Apache server on it. Everything works fine up to the point
where I want to execute a cgi script which is a perl program
(I checked that cgi scripts that based on shell commands do not cause
problems).
I noticed that the origin of the problem is that I can run my script
from the command line as:
perl myscript.pl
however calling it without explicitely naming perl, as
myscript.pl
results in the following error message
bash: /home/httpd/cgi-bin/myscript.pl: No such file or directory

I do have #!/usr/bin/perl as a first line of the script.
Can somebody explain me what is wrong here?
TIA,
Gennady.



 Wed, 18 Jun 1902 08:00:00 GMT   
 running perl script on linux

First, change the files mode to an executable (chmod 755 myscript.pl).
Then to run it at the command prompt: ./myscript.pl  That appends the
present working directory to the front end.  If it doesn't run when
calling it via url (http://your.box's.url/cgi-bin/myscript.pl) then the
problem is with your apache configuration, make sure your access.conf
file (in /etc/httpd/conf/) has somthing like this in it:

<Directory /path/to/cgi-bin>
AllowOverride None
Options ExecCGI
</Directory>

If it doesn't, add it and restart the httpd (run: killproc httpd -HUP).

Stu



 Wed, 18 Jun 1902 08:00:00 GMT   
 running perl script on linux
in addition to other reply...

This might be painfully obvious... but is 'perl' at /usr/bin/perl on your
system? (which perl)

on that note... I usually set up symlinks to point to 'typical' executable
locations for convenience.  This isn't a big deal on small scale... but for
a large amount of scripts... might be more convenient to make the symlinks
than fix the #! statement at the top of the files

ln -s /usr/sbin/perl /usr/local/bin/perl
ln -s /usr/sbin/perl /usr/bin/perl

etc...



 Wed, 18 Jun 1902 08:00:00 GMT   
 running perl script on linux

If a script runs as 'perl script.cgi', but not as './script.cgi' the most
likely newbie problem (other than the first line) is that the script has
been infected with MS.  DOS/Win end text lines with CR-LF (\r\n), I hear
that Mac just uses CR (\r) and Unix just uses LF (\n).  So the problem is
that bash cannot find "perl^M" instead of "perl", but you cannot see that
because a carriage return really is a carriage return on the screen (in
the middle of error message).

Always use ASCII text mode for ftp upload/download of text files and
scripts between different OS's.

Pick one: Bill ('Clinton', 'Gates', 'me later')

--
David Efflandt  effla...@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://thunder.prohosting.com/~cv-elgin/  http://cgi-help.virtualave.net/



 Wed, 18 Jun 1902 08:00:00 GMT   
 running perl script on linux
You are exactly right, David!!!

That was my problem - CR-LF from MS, rather than LF.
After editing on linux and saving the file, everything works as it should be.

Thanks everybody for answering my question. It is a great help,
and I really appreciate it.

Gennady.



 Wed, 18 Jun 1902 08:00:00 GMT   
 running perl script on linux
You are exactly right, David!!!

That was my problem - CR-LF from MS, rather than LF.
After editing on linux and saving the file, everything works as it should be.

Thanks everybody for answering my question. It is a great help,
and I really appreciate it.

Gennady.



 Wed, 18 Jun 1902 08:00:00 GMT   
 
   [ 6 post ] 

Similar Threads

1. after update of perl, apache cant run perl scripts

2. Incomplete output from crontab email: running shell scripts from a perl script

3. Run a perl-script inside another script

4. Problem with running Perl Script with Apache on Linux

5. Help:apache did not run perl script

6. How to use .redirect to run a perl script

7. Cannot run perl scripts in Apache when file opened via Samba

8. Running perl script as sendmail autoresponder

9. running perl scripts on Solaris 9


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software