LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-05-2004, 10:48 AM   #1
servnov
Member
 
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

Rep: Reputation: 30
#! does not seem to work in cgi-bin?? (script execution)


I wrote some very simple perl and python scripts for testing in the cgi-bin/ of apache. I did chmod 755 on the script and all /var/www/ dirs are owned by user and grp root. I even invoked perl and python manually on the scripts by typing 'python testscript.py', etc. I cannot seem to invoke execution from ./testscript.py or the full pathname (which is the same either way). Thus, the #! won't work and when viewed from a web-browser I get "internal server error".

Please help. I am thinking it might have to do chroot or something not allowing the script to see after #!. Thanks.

(and yes, the #! matches with the correct path :P)
 
Old 12-05-2004, 10:50 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 255Reputation: 255Reputation: 255
Is Apache configured correctly to execute such files, in the cgi-bin directory defined.. etc?
 
Old 12-05-2004, 12:52 PM   #3
jspenguin
Member
 
Registered: Feb 2003
Location: Wichita, KS
Distribution: Heavily modified Redhat
Posts: 194

Rep: Reputation: 30
What is th #! line? Do you have the correct path to the interpreter?
 
Old 12-05-2004, 05:13 PM   #4
servnov
Member
 
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

Original Poster
Rep: Reputation: 30
I fixed the #! problem. It seemed to be some weird problem from writing it in notepad. I rewrote it in vi and it worked 100%.

But, I still get the "internal server error". I looked through http.conf and everything looked fine and I even experimented some. Any ideas?
 
Old 12-05-2004, 05:21 PM   #5
jspenguin
Member
 
Registered: Feb 2003
Location: Wichita, KS
Distribution: Heavily modified Redhat
Posts: 194

Rep: Reputation: 30
Ah, the old \r\n vs. \n problem. Run dos2unix on the file, it should work fine.
 
Old 12-05-2004, 05:26 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally posted by servnov
I fixed the #! problem. It seemed to be some weird problem from writing it in notepad. I rewrote it in vi and it worked 100%.

But, I still get the "internal server error". I looked through http.conf and everything looked fine and I even experimented some. Any ideas?
So you have something like this for .cgi scripts and your py and pl scripts?

AddHandler cgi-script .cgi

For all of your types of scripts to be executed from the browser and server so apache knows what to do with such scripts? You even experimented some? Care to ellaborate on what you experimented with or did?

Why not link or post your httpd.conf file if your not sure?
 
Old 12-06-2004, 08:23 AM   #7
servnov
Member
 
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

Original Poster
Rep: Reputation: 30
Hey, thanks for help. The notepad problem was appending ^M to the end of each line. (vi didnt show this to me while editing it). Rewriting in a real text editor like vi solved it.

For cgi scripts do you need to manually redirect stdout? The cgi tests that came with apache in the cgi-bin/ are working fine. So its a script problem. Feel free to write an example py script or something...(maybe i need to import cgi..)
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cgi-bin script: turn off computer hamish Linux - General 2 10-21-2005 10:46 AM
cgi-bin error regarding perl script hamish Linux - Software 11 12-09-2004 11:16 AM
CGI to work out side of cgi-bin? crashedspine Linux - Newbie 13 09-02-2004 09:49 PM
REMOTE_HOST in a CGI-bin script trouble gary knott Linux - Networking 4 11-12-2003 06:33 PM
Running a shell script via CGI-BIN chrisk5527 Linux - General 3 05-09-2003 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration