LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 12-14-2004, 08:42 AM   #1
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Rep: Reputation: 15
Perl problems


Hi all,

Perl is intalled and running on my box. If I type the following at the command line, my script executes fine:

perl /var/www/cgi-bin/hello.cgi

I have the correct permissions in the cgi-bin (I think) and Apache is pointing at the right folder for running scripts, however my file keeps throwing the following error:

Quote:
Can't open perl script "/var/www/cgi-bin/hello.cgi": No such file or directory.
Use -S to search $PATH for it.
The code itself is blindingly simple... good ol' "Hello World!"

Code:
#!/usr/bin/perl
print "Hello, world!\n";
That's it. I've checked the path the Perl and is seems right. Other system info is:

Fedora 3
KDE
Perl 5.8.5
Apache 2.0.52

What am I doing wrong? All I can find in Google is references to what's new in Perl 5.8.5!

Cheers,

G

Last edited by gharvey; 12-14-2004 at 08:58 AM.
 
Old 12-14-2004, 09:02 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,771

Rep: Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283
Just 2 things:
Is hello.cgi executable? chmod +755 hello.cgi
When you use perl scripts with a webserver you must use
Code:
print "Content-type: text/html\n\n";
before the output of any other data.
Regards
 
Old 12-14-2004, 09:27 AM   #3
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Original Poster
Rep: Reputation: 15
Hi!

Checked permissions - they're correct. Added the header to the code (forgot about that with Perl - thanks!) but still the same error...

Any other suggestions?

G
 
Old 12-14-2004, 10:40 AM   #4
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Original Poster
Rep: Reputation: 15
I think I may have jumped the gun a bit when entering my error! I put what I thought it was - brainwashed myself on Google before posting!

This is my actual error - it's pretty close, but might have clues as to the problem:

Quote:
Can't open perl script "\r": No such file or directory.
Use -S to search $PATH for it.
It's that \r that's got me curious... what the hell does that mean?? I'm calling http://my.server.co.uk/cgi-bin/hello.cgi - no \r to be seen!

G
 
Old 12-14-2004, 11:58 AM   #5
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Original Poster
Rep: Reputation: 15
The \r is gone now - figured out what that was - looked like Linux didn't like the Windows line endings - converted to Unix and no probs there. There's a new error instead!!

Quote:
(2)No such file or directory: exec of '/var/www/cgi-bin/hello.cgi' failed
Premature end of script headers: hello.cgi
This is driving me nuts! The worst part is that it's damned near impossible to get a decent search out of Google using \(): etc.! *sigh*

Cheers,

G
 
Old 12-14-2004, 12:34 PM   #6
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Original Poster
Rep: Reputation: 15
Starting to get somewhere on this now... Leave a newbie alone for long enough and they'll stumble across the answers!



Anyways, the first error was caused by Windows line endings - fixed!

The second error I can now fix, but it's still weird. The behaviour is as follows.

1. Script won't execute - error as detailed in post above
2. Change the # line to have a "-w" at the end of it
3. Script works
4. Change # line back
5. Script continues to work fine forever!

Why does it need the "-w" the first time it runs?

Thanks,

G
 
Old 12-14-2004, 12:38 PM   #7
egag
Senior Member
 
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,721

Rep: Reputation: 52
-----------
#!/usr/bin/perl
-----------

is perl installed in that dir. ? ( maybe #!/usr/local/bin/perl....)

egag
 
Old 12-14-2004, 12:39 PM   #8
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Original Poster
Rep: Reputation: 15
Yes - the right Perl dir is being referenced - I've moved on from that now - see my last post.

Thanks,

G
 
Old 12-21-2004, 07:21 AM   #9
gharvey
LQ Newbie
 
Registered: Dec 2004
Location: London, UK
Distribution: Ubuntu, Debian, CentOS
Posts: 26

Original Poster
Rep: Reputation: 15
I guess no one knows what's wrong here...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
serious perl problems vmlinuz101 Linux From Scratch 1 11-27-2006 09:29 AM
problems with perl.. amachine7 Mandriva 2 01-02-2005 03:25 PM
Perl problems rickenbacherus Linux - Software 1 06-08-2004 11:57 PM
Perl problems Vindane Linux - Software 1 06-05-2004 05:09 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM


All times are GMT -5. The time now is 02:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration