This is a discussion on Running cgi scrips within the Linux Web Servers forums, part of the Web Server and Related Forums category; Help I am trying to run some cgi scripts on my server and have no luck in doing it. In ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Help
I am trying to run some cgi scripts on my server and have no luck in doing it. In my error logs I get "Premature end of script headers:" Any Idea as to what is going wrong? I have these lines in my httpd.conf file: ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" Addhandler cgi-script .cgi The script files are executable Is their something I have missed? John |
|
|||
|
John Rusinko wrote:
> Help > > I am trying to run some cgi scripts on my server and have no luck in > doing it. In my error logs I get "Premature end of script headers:" Any > Idea as to what is going wrong? I have these lines in my httpd.conf file: > ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" > Addhandler cgi-script .cgi > > The script files are executable > > Is their something I have missed? > > John > OK, I have done some more digging, I have a small cgi script to just test things out: #!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello"; That's it, nothing else. when I try to run this script from the command line using the command /var/www/cgi-bin/test.pl I get ": bad interpreter: No such file or directory/perl" If I check to see where perl is on my system, it is in the directory /usr/bin/. I have also added .pl to the Addhandler cgi-script in the config file. Any Ideas?? John |
|
|||
|
John Rusinko <ponyxprs@rcn.com> writes:
> #!/usr/bin/perl > print "Content-type: text/html\n\n"; > print "Hello"; > > That's it, nothing else. when I try to run this script from the > command line using the command /var/www/cgi-bin/test.pl I get ": bad > interpreter: No such file or directory/perl" If I check to see where > perl is on my system, it is in the directory /usr/bin/. I have also > added .pl to the Addhandler cgi-script in the config file. Did you write this script on a windows system and copy it over? If so you may be trying to call /usr/bin/perl\r -- Chris |
|
|||
|
Chris Morris wrote:
> John Rusinko <ponyxprs@rcn.com> writes: > >>#!/usr/bin/perl >>print "Content-type: text/html\n\n"; >>print "Hello"; >> >>That's it, nothing else. when I try to run this script from the >>command line using the command /var/www/cgi-bin/test.pl I get ": bad >>interpreter: No such file or directory/perl" If I check to see where >>perl is on my system, it is in the directory /usr/bin/. I have also >>added .pl to the Addhandler cgi-script in the config file. > > > Did you write this script on a windows system and copy it over? > If so you may be trying to call /usr/bin/perl\r > nope, used VI right from the console, what does the \r do? |
|
|||
|
John Rusinko <ponyxprs@rcn.com> writes:
> Chris Morris wrote: > > John Rusinko <ponyxprs@rcn.com> writes: > > > >>#!/usr/bin/perl > >>print "Content-type: text/html\n\n"; > >>print "Hello"; > >> > >>That's it, nothing else. when I try to run this script from the > >>command line using the command /var/www/cgi-bin/test.pl I get ": bad > >>interpreter: No such file or directory/perl" If I check to see where > >>perl is on my system, it is in the directory /usr/bin/. I have also > >>added .pl to the Addhandler cgi-script in the config file. > > Did you write this script on a windows system and copy it over? > > If so you may be trying to call /usr/bin/perl\r > > > nope, used VI right from the console, what does the \r do? Windows line ending is \r\n So on a unix system expecting the line ending \n the path to the interpreter assumes the \r as well. What happens if you type 'perl /var/www/cgi-bin/test.pl' on the command line? -- Chris |
|
|||
|
Chris Morris wrote:
> John Rusinko <ponyxprs@rcn.com> writes: > >>Chris Morris wrote: >> >>>John Rusinko <ponyxprs@rcn.com> writes: >>> >>> >>>>#!/usr/bin/perl >>>>print "Content-type: text/html\n\n"; >>>>print "Hello"; >>>> >>>>That's it, nothing else. when I try to run this script from the >>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad >>>>interpreter: No such file or directory/perl" If I check to see where >>>>perl is on my system, it is in the directory /usr/bin/. I have also >>>>added .pl to the Addhandler cgi-script in the config file. >>> >>>Did you write this script on a windows system and copy it over? >>>If so you may be trying to call /usr/bin/perl\r >>> >> >>nope, used VI right from the console, what does the \r do? > > > Windows line ending is \r\n > > So on a unix system expecting the line ending \n the path to the > interpreter assumes the \r as well. > > What happens if you type 'perl /var/www/cgi-bin/test.pl' on the > command line? > I get: "Content-type: texl/html Hello" With out the quotes of course, could it be the the script does not know how to find the perl interpreter? Do I have to add something to a PATH variable? John |
|
|||
|
John Rusinko <ponyxprs@rcn.com> writes:
> Chris Morris wrote: > > John Rusinko <ponyxprs@rcn.com> writes: > >>Chris Morris wrote: > >>>John Rusinko <ponyxprs@rcn.com> writes: > >>>>#!/usr/bin/perl > >>>>print "Content-type: text/html\n\n"; > >>>>print "Hello"; > >>>> > >>>>That's it, nothing else. when I try to run this script from the > >>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad > >>>>interpreter: No such file or directory/perl" If I check to see where > > > > What happens if you type 'perl /var/www/cgi-bin/test.pl' on the > > command line? > > > [it works] > > With out the quotes of course, could it be the the script does not > know how to find the perl interpreter? The error message looks like it's unable to find it, yes. > Do I have to add something to a PATH variable? Shouldn't do, you have an absolute path in the shebang line. What does 'which perl' say? What are the file permissions of /var/www/cgi-bin/test.pl and /usr/bin/perl? -- Chris |
|
|||
|
Chris Morris wrote:
> John Rusinko <ponyxprs@rcn.com> writes: > >>Chris Morris wrote: >> >>>John Rusinko <ponyxprs@rcn.com> writes: >>> >>>>Chris Morris wrote: >>>> >>>>>John Rusinko <ponyxprs@rcn.com> writes: >>>>> >>>>>>#!/usr/bin/perl >>>>>>print "Content-type: text/html\n\n"; >>>>>>print "Hello"; >>>>>> >>>>>>That's it, nothing else. when I try to run this script from the >>>>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad >>>>>>interpreter: No such file or directory/perl" If I check to see where >>> >>>What happens if you type 'perl /var/www/cgi-bin/test.pl' on the >>>command line? >>> >> >>[it works] >> >>With out the quotes of course, could it be the the script does not >>know how to find the perl interpreter? > > > The error message looks like it's unable to find it, yes. > > >>Do I have to add something to a PATH variable? > > > Shouldn't do, you have an absolute path in the shebang line. > > What does 'which perl' say? What are the file permissions of > /var/www/cgi-bin/test.pl and /usr/bin/perl? > which perl says "/usr/bin/perl" Permissions for both /var/www/cgi-bin/test.pl and /usr/bin/perl are Owner: root Group: root Read: Owner, Group, Others Write: Owner Exec: Owner, Group, Others |
|
|||
|
Does your apache run chrooted?
John Rusinko <ponyxprs@rcn.com> writes: > Chris Morris wrote: > > John Rusinko <ponyxprs@rcn.com> writes: > > > >>Chris Morris wrote: > >> > >>>John Rusinko <ponyxprs@rcn.com> writes: > >>> > >>>>Chris Morris wrote: > >>>> > >>>>>John Rusinko <ponyxprs@rcn.com> writes: > >>>>> > >>>>>>#!/usr/bin/perl > >>>>>>print "Content-type: text/html\n\n"; > >>>>>>print "Hello"; > >>>>>> > >>>>>>That's it, nothing else. when I try to run this script from the > >>>>>>command line using the command /var/www/cgi-bin/test.pl I get ": bad > >>>>>>interpreter: No such file or directory/perl" If I check to see where > >>> > >>>What happens if you type 'perl /var/www/cgi-bin/test.pl' on the > >>>command line? > >>> > >> > >>[it works] > >> > >>With out the quotes of course, could it be the the script does not > >>know how to find the perl interpreter? > > > > > > The error message looks like it's unable to find it, yes. > > > > > >>Do I have to add something to a PATH variable? > > > > > > Shouldn't do, you have an absolute path in the shebang line. > > > > What does 'which perl' say? What are the file permissions of > > /var/www/cgi-bin/test.pl and /usr/bin/perl? > > > which perl says "/usr/bin/perl" > > Permissions for both /var/www/cgi-bin/test.pl and /usr/bin/perl are > > Owner: root > Group: root > Read: Owner, Group, Others > Write: Owner > Exec: Owner, Group, Others |
|
|||
|
Redhat, Debian, FreeBSD, Windows
High Speed Servers with 1000GB Traffic. starting at $85 http://www.globalregister.net |