Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47142 > unrolled thread
| Started by | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-06-05 12:54 -0700 |
| Last post | 2013-06-09 08:21 +1000 |
| Articles | 20 on this page of 37 — 10 participants |
Back to article view | Back to comp.lang.python
Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-05 12:54 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser John Gordon <gordon@panix.com> - 2013-06-05 20:13 +0000
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-06 06:14 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser rurpy@yahoo.com - 2013-06-05 13:56 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-06 07:03 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser rurpy@yahoo.com - 2013-06-05 14:18 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-06 08:21 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser rurpy@yahoo.com - 2013-06-05 15:36 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-06 11:37 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-05 20:27 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-05 23:25 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Cameron Simpson <cs@zip.com.au> - 2013-06-06 10:32 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-05 20:23 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-06 03:53 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser rurpy@yahoo.com - 2013-06-06 11:40 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-06 12:01 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-06 12:08 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Lele Gaifax <lele@metapensiero.it> - 2013-06-06 21:26 +0200
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-06 12:30 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Skip Montanaro <skip@pobox.com> - 2013-06-06 14:35 -0500
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-06 13:07 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Lele Gaifax <lele@metapensiero.it> - 2013-06-06 22:28 +0200
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-07 00:20 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-07 00:51 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser MRAB <python@mrabarnett.plus.com> - 2013-06-07 15:32 +0100
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-07 11:24 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser MRAB <python@mrabarnett.plus.com> - 2013-06-07 21:47 +0100
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-07 23:53 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-08 17:01 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-08 08:36 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-09 02:03 +1000
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-08 09:56 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Michael Torrie <torriem@gmail.com> - 2013-06-08 15:17 -0600
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-08 14:33 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser nagia.retsina@gmail.com - 2013-06-08 22:27 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-09 03:42 -0700
Re: Errin when executing a cgi script that sets a cookie in the browser Chris Angelico <rosuav@gmail.com> - 2013-06-09 08:21 +1000
Page 1 of 2 [1] 2 Next page →
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-05 12:54 -0700 |
| Subject | Errin when executing a cgi script that sets a cookie in the browser |
| Message-ID | <400ea041-adcf-4640-8872-f81808f7d402@googlegroups.com> |
Since the other thread gone into the wild, i choosed not to participate any longer and i state the question in this new thread.
'python files.py' interprets without an error.
Problem is that when via browser - http://superhost.gr/cgi-bin/koukos.py
i receive the following:
-------------------------------
root@nikos [/home/nikos/www/cgi-bin]# ls
./ ../ convert.py* files.py* .htaccess koukos.py* metrites.py* pelatologio.py*
root@nikos [/home/nikos/www/cgi-bin]# tail -F /usr/local/apache/logs/error_log &
root@nikos [/home/nikos/www/cgi-bin]# [Wed Jun 05 22:47:43 2013] [error] [client 79.103.41.173] (2)No such file or directory: exec of '/home/nikos/public_html/c gi-bin/koukos.py' failed
[Wed Jun 05 22:47:43 2013] [error] [client 79.103.41.173] Premature end of scrip t headers: koukos.py
----------------------------------
What file does the error complain it cannot find? I do not understand its message. Here is the code of koukos.py
-----------------------------
#!/usr/bin/python
# coding=utf-8
import cgitb; cgitb.enable()
import cgi, os, sys, locale, codecs
from http import cookies
#needed line, script does *not* work without it
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach())
# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
nikos = cookie.get('nikos')
# if visitor cookie does exist
if nikos:
message = "ΑΠΟ ΤΗΝ ΕΠΟΜΕΝΗ ΕΠΙΣΚΕΨΗ ΣΟΥ ΘΑ ΣΕ ΥΠΟΛΟΓΙΖΩ ΩΣ ΕΠΙΣΚΕΠΤΗ ΑΥΞΑΝΟΝΤΑΣ ΤΟΝ ΜΕΤΡΗΤΗ!"
cookie['nikos'] = 'admin'
cookie['nikos']['path'] = '/'
cookie['nikos']['expires'] = -1 #this cookie will expire now
else:
message = "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΝ ΣΕ ΕΙΔΑ, ΔΕΝ ΣΕ ΞΕΡΩ, ΔΕΝ ΣΕ ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΝ Ο ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!"
cookie['nikos'] = 'admin'
cookie['nikos']['path'] = '/'
cookie['nikos']['expires'] = 60*60*24*30*12 #this cookie will expire in a year
print( cookie, "Content-type: text/html; charset=utf-8\n", message )
sys.exit(0)
---------------------------------
All it tries to do is to set a cookie.
[toc] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2013-06-05 20:13 +0000 |
| Message-ID | <koo65h$8kt$1@reader1.panix.com> |
| In reply to | #47142 |
In <400ea041-adcf-4640-8872-f81808f7d402@googlegroups.com> =?ISO-8859-7?B?zenq/Ovh7/Igyu/98eHy?= <nikos.gr33k@gmail.com> writes:
> 'python files.py' interprets without an error.
> Problem is that when via browser - http://superhost.gr/cgi-bin/koukos.py
> i receive the following:
Why should 'files.py' have any relation to 'koukous.py'?
> What file does the error complain it cannot find? I do not understand its
> message. Here is the code of koukos.py
> -----------------------------
> #!/usr/bin/python
Does /usr/bin/python exist? Scripts can throw a 'No such file or directory'
or 'Command not found' error if they begin with a shebang line which refers
to a nonexistent program.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 06:14 +1000 |
| Message-ID | <mailman.2761.1370463268.3114.python-list@python.org> |
| In reply to | #47142 |
On Thu, Jun 6, 2013 at 5:54 AM, Νικόλαος Κούρας <nikos.gr33k@gmail.com> wrote: > print( cookie, "Content-type: text/html; charset=utf-8\n", message ) > Do you know what this does? Try it at the console. See what it outputs. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | rurpy@yahoo.com |
|---|---|
| Date | 2013-06-05 13:56 -0700 |
| Message-ID | <386bdf4a-53ae-4312-af5d-e28ef10ada42@googlegroups.com> |
| In reply to | #47142 |
On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote: >... > print( cookie, "Content-type: text/html; charset=utf-8\n", message ) >... If you look in the Apache error log file, you will see something like, [Wed Jun 05 16:39:14 2013] [error] [client 192.168.0.1] malformed header from script. Bad header= \xce\x91\xce\xa0\xce\x9f \xce\x94\xce\xa9 \xce\x9a\xce\x91\xce\x99 \xce\xa3\xce\xa4\xce\x9f \xce\x95\xce: koukos.py which is saying that the 'message' text is being interpreted as being part of the headers. You are missing a blank line between the header lines and the page text. That is, I think you want, print( cookie, "Content-type: text/html; charset=utf-8\n\n", message ) (ie, note the two \n's after the "utf-8" test.)
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 07:03 +1000 |
| Message-ID | <mailman.2765.1370466218.3114.python-list@python.org> |
| In reply to | #47149 |
On Thu, Jun 6, 2013 at 6:56 AM, <rurpy@yahoo.com> wrote: > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote: >>... >> print( cookie, "Content-type: text/html; charset=utf-8\n", message ) >>... > > If you look in the Apache error log file, you will see something like, > > [Wed Jun 05 16:39:14 2013] [error] [client 192.168.0.1] malformed header from script. Bad header= \xce\x91\xce\xa0\xce\x9f \xce\x94\xce\xa9 \xce\x9a\xce\x91\xce\x99 \xce\xa3\xce\xa4\xce\x9f \xce\x95\xce: koukos.py > > which is saying that the 'message' text is being interpreted as > being part of the headers. > > You are missing a blank line between the header lines and the > page text. That is, I think you want, > > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message ) > > (ie, note the two \n's after the "utf-8" test.) But that won't solve it either. The default separator for print is a space, so this will indent his Content-type line by one space. Nikos, do you know what effect that will have? If not, research HTTP. RFC 2616 is a good place to start. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | rurpy@yahoo.com |
|---|---|
| Date | 2013-06-05 14:18 -0700 |
| Message-ID | <9d8cdf1b-cc79-4266-9bf5-ce8b690ac74a@googlegroups.com> |
| In reply to | #47151 |
On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote: > On Thu, Jun 6, 2013 at 6:56 AM, <rurpy@yahoo.com> wrote: > > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote: > >>... > >> print( cookie, "Content-type: text/html; charset=utf-8\n", message ) > >>... > > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message ) > > (ie, note the two \n's after the "utf-8" test.) > > But that won't solve it either. The default separator for print is a > space, so this will indent his Content-type line by one space. Ah, quite right. Something like print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message ) then.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 08:21 +1000 |
| Message-ID | <mailman.2768.1370470877.3114.python-list@python.org> |
| In reply to | #47152 |
On Thu, Jun 6, 2013 at 7:18 AM, <rurpy@yahoo.com> wrote: > On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote: >> On Thu, Jun 6, 2013 at 6:56 AM, <rurpy@yahoo.com> wrote: >> > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote: >> >>... >> >> print( cookie, "Content-type: text/html; charset=utf-8\n", message ) >> >>... >> > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message ) >> > (ie, note the two \n's after the "utf-8" test.) >> >> But that won't solve it either. The default separator for print is a >> space, so this will indent his Content-type line by one space. > > Ah, quite right. Something like > > print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message ) > > then. Or change the sep, or concatenate with + instead of using , between them. Or put them on separate lines. Anything like that would work. And it's really easy to try things out interactively to see what they'll do... ChrisA
[toc] | [prev] | [next] | [standalone]
| From | rurpy@yahoo.com |
|---|---|
| Date | 2013-06-05 15:36 -0700 |
| Message-ID | <de6a4ec5-d20d-4cf9-a4d4-6f9647d0b138@googlegroups.com> |
| In reply to | #47155 |
On 06/05/2013 04:21 PM, Chris Angelico wrote: > On Thu, Jun 6, 2013 at 7:18 AM, <rurpy@yahoo.com> wrote: >> On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote: ..[...] >> Ah, quite right. Something like >> >> print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message ) >> >> then. > > Or change the sep, or concatenate with + instead of using , between > them. Or put them on separate lines. Anything like that would work. Of course. > And it's really easy to try things out interactively to see what > they'll do... Sure, once one makes the connection between "Server Error" and missing "\n" which is where Νικόλαος was stuck I'm guessing.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-06-06 11:37 +1000 |
| Message-ID | <mailman.2777.1370482647.3114.python-list@python.org> |
| In reply to | #47156 |
On Thu, Jun 6, 2013 at 8:36 AM, <rurpy@yahoo.com> wrote: >> And it's really easy to try things out interactively to see what >> they'll do... > > Sure, once one makes the connection between "Server Error" and missing "\n" > which is where Νικόλαος was stuck I'm guessing. I know that's a bit of a jump. That's why, right back when he first posted his problem, I quoted _that one line_ and pointed him to the interactive interpreter. I'm pretty sure he still isn't reading my posts... or, most likely, anyone's. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-05 20:27 -0700 |
| Message-ID | <17ed2c0c-5ebf-401a-a59a-9d270d0c43a8@googlegroups.com> |
| In reply to | #47155 |
Τη Πέμπτη, 6 Ιουνίου 2013 1:21:08 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Thu, Jun 6, 2013 at 7:18 AM, <rurpy@yahoo.com> wrote: > > > On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote: > > >> On Thu, Jun 6, 2013 at 6:56 AM, <rurpy@yahoo.com> wrote: > > >> > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote: > > >> >>... > > >> >> print( cookie, "Content-type: text/html; charset=utf-8\n", message ) > > >> >>... > > >> > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message ) > > >> > (ie, note the two \n's after the "utf-8" test.) > > >> > > >> But that won't solve it either. The default separator for print is a > > >> space, so this will indent his Content-type line by one space. > > > > > > Ah, quite right. Something like > > > > > > print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message ) > > > > > > then. > > > > Or change the sep, or concatenate with + instead of using , between > > them. Or put them on separate lines. Anything like that would work. > > And it's really easy to try things out interactively to see what > > they'll do... > > > > ChrisA Thi is failing also with same error: print( cookie ) print( '''Content-type: text/html; charset=utf-8\n''' ) print( message )
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-05 23:25 -0700 |
| Message-ID | <8ff3a8c7-3ca4-49e5-8153-042d535a792e@googlegroups.com> |
| In reply to | #47182 |
root@nikos [~]# chmod 755 /var/log root@nikos [~]# chmod 755 /var/log/httpd root@nikos [~]# chmod 666 /var/log/httpd/suexec.log root@nikos [~]# chmod 755 /usr/local/apache root@nikos [~]# chmod 755 /usr/local/apache/logs/ root@nikos [~]# chmod 666 /usr/local/apache/logs/error_log and then execute via browser: http://superhost.gr/cgi-bin/koukos.py still same error appearing: [Thu Jun 06 09:23:54 2013] [error] [client 79.103.41.173] suexec failure: could not open log file [Thu Jun 06 09:23:54 2013] [error] [client 79.103.41.173] fopen: Permission denied [Thu Jun 06 09:23:54 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py
[toc] | [prev] | [next] | [standalone]
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2013-06-06 10:32 +1000 |
| Message-ID | <mailman.2779.1370482916.3114.python-list@python.org> |
| In reply to | #47152 |
On 05Jun2013 14:18, rurpy@yahoo.com <rurpy@yahoo.com> wrote:
| On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote:
| > On Thu, Jun 6, 2013 at 6:56 AM, <rurpy@yahoo.com> wrote:
| > > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote:
| > >>...
| > >> print( cookie, "Content-type: text/html; charset=utf-8\n", message )
| > >>...
| > > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message )
| > > (ie, note the two \n's after the "utf-8" test.)
| >
| > But that won't solve it either. The default separator for print is a
| > space, so this will indent his Content-type line by one space.
|
| Ah, quite right. Something like
|
| print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message )
|
| then.
Unless "cookie" already has a newline. Then you'll end the headers there:-)
A more robust approach might be to build a dict (or possibly better,
list) of headers without newlines and then as a separate act to
print them with newlines and add the spacer newline later, before
writing the message body.
Cheers,
--
Cameron Simpson <cs@zip.com.au>
Drill for oil? You mean drill into the ground to try and find oil?
You're crazy.
--Drillers whom Edwin L. Drake tried to enlist to his project
to drill for oil in 1859.
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-05 20:23 -0700 |
| Message-ID | <ff4b7602-6eb5-4b05-abf6-d164f28c5225@googlegroups.com> |
| In reply to | #47152 |
Τη Πέμπτη, 6 Ιουνίου 2013 12:18:39 π.μ. UTC+3, ο χρήστης ru...@yahoo.com έγραψε: > On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote: > > > On Thu, Jun 6, 2013 at 6:56 AM, <rurpy@yahoo.com> wrote: > > > > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote: > > > >>... > > > >> print( cookie, "Content-type: text/html; charset=utf-8\n", message ) > > > >>... > > > > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message ) > > > > (ie, note the two \n's after the "utf-8" test.) > > > > > > But that won't solve it either. The default separator for print is a > > > space, so this will indent his Content-type line by one space. > > > > Ah, quite right. Something like > > > > print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message ) > > > > then. print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message ) or by trying: print( cookie + "\nContent-type: text/html; charset=utf-8\n\n" + message ) the output is for both: nikos@superhost.gr [~]# tail -F /usr/local/apache/logs/error_log & nikos@superhost.gr [~]# [Thu Jun 06 06:20:11 2013] [error] [client 79.103.41.173] (2)No such file or directory: exec of '/home/nikos/public_html/cgi-bin/koukos.py' failed [Thu Jun 06 06:20:11 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-06 03:53 -0700 |
| Message-ID | <c7437ebf-48e4-4873-832c-ac5529568718@googlegroups.com> |
| In reply to | #47181 |
I have re-enabled 'suexec' and set cgi as default phphandler and then trying: print( cookie ) print( '''Content-type: text/html; charset=utf-8\n''' ) print( message ) --------------------------------- nikos@superhost.gr [~/www/data/apps]# [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] suexec failure: could not open log file [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] fopen: Permission denied [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py Even if dissable/enable suexec still this output error.
[toc] | [prev] | [next] | [standalone]
| From | rurpy@yahoo.com |
|---|---|
| Date | 2013-06-06 11:40 -0700 |
| Message-ID | <61b47852-9e34-4d9a-9ee3-9801f4cc3065@googlegroups.com> |
| In reply to | #47208 |
On 06/06/2013 04:53 AM, Νικόλαος Κούρας wrote:> I have re-enabled 'suexec' and set cgi as default phphandler and then trying: > > print( cookie ) > print( '''Content-type: text/html; charset=utf-8\n''' ) > print( message ) > > --------------------------------- > nikos@superhost.gr [~/www/data/apps]# [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] suexec failure: could not open log file > [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] fopen: Permission denied > [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py > > Even if dissable/enable suexec still this output error. This is only a guess but... The permissions on koukos.py have to be exactly right. Obviously if they are too restrictive Apache won't be able to read or execute it. But they can't be to open either -- in particular the file must have execute permission and must not have write permission for either group or others (write for user only). If the permissions are too open, Apache will try to write an error message to suexec.log. I suspect that your permissions (or file owner) is wrong on your suexec.log file (or containing directory) and that is the cause of the "could not open log file " message. So I think you have too problems: wrong permissions on koukos.py and wrong owner or permissions on suexec.log. For reference this is working here: -rw-r--r-- 1 apache apache 314 Jun 6 12:19 /var/log/httpd/suexec.log -rwxr-xr-x 1 me me 1113 Jun 5 14:40 koukos.py You'll need to adjust things for your particular Apache environment. As I said, this is only a guess. Hope it helps.
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-06 12:01 -0700 |
| Message-ID | <61f69d27-a041-48a3-99aa-be59ad817db9@googlegroups.com> |
| In reply to | #47254 |
Τη Πέμπτη, 6 Ιουνίου 2013 9:40:04 μ.μ. UTC+3, ο χρήστης ru...@yahoo.com έγραψε: > On 06/06/2013 04:53 AM, Νικόλαος Κούρας wrote:> I have re-enabled 'suexec' and set cgi as default phphandler and then trying: > > > > > > print( cookie ) > > > print( '''Content-type: text/html; charset=utf-8\n''' ) > > > print( message ) > > > > > > --------------------------------- > > > nikos@superhost.gr [~/www/data/apps]# [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] suexec failure: could not open log file > > > [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] fopen: Permission denied > > > [Thu Jun 06 13:51:28 2013] [error] [client 79.103.41.173] Premature end of script headers: koukos.py > > > > > > Even if dissable/enable suexec still this output error. > > > > This is only a guess but... > > > > The permissions on koukos.py have to be exactly right. > > Obviously if they are too restrictive Apache won't be > > able to read or execute it. But they can't be to open > > either -- in particular the file must have execute > > permission and must not have write permission for either > > group or others (write for user only). > > > > If the permissions are too open, Apache will try to write > > an error message to suexec.log. I suspect that your > > permissions (or file owner) is wrong on your suexec.log > > file (or containing directory) and that is the cause of > > the "could not open log file " message. > > > > So I think you have too problems: wrong permissions on > > koukos.py and wrong owner or permissions on suexec.log. > > > > For reference this is working here: > > -rw-r--r-- 1 apache apache 314 Jun 6 12:19 /var/log/httpd/suexec.log > > > > -rwxr-xr-x 1 me me 1113 Jun 5 14:40 koukos.py > > > > You'll need to adjust things for your particular Apache > > environment. > > > > As I said, this is only a guess. Hope it helps. Hello! thanks for trying to help. Here they are: nikos@superhost.gr [~/www/cgi-bin]# ls -l koukos.py -rwxr-xr-x 1 nikos nikos 1160 Jun 6 06:27 koukos.py* nikos@superhost.gr [~/www/cgi-bin]# ls -l /var/log/httpd/suexec.log -rw-rw-rw- 1 root apache 0 Jun 1 02:52 /var/log/httpd/suexec.log nikos@superhost.gr [~/www/cgi-bin]# ls -l /usr/local/apache/logs/suexec_log -rw-rw-r-- 1 root apache 675097 Jun 6 21:43 /usr/local/apache/logs/suexec_log I have applied to them the group 'apache' so Apache User can utilize them. But its still a wonder to me why two different suexec logs exist. Please tell me wht else you want me to try.
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-06 12:08 -0700 |
| Message-ID | <38f7bb64-4312-4ce1-9380-ee91065b3294@googlegroups.com> |
| In reply to | #47257 |
Since cPanel is in charge of apache i ahve even: chown nobody:nobody to both of the suexec logs. nikos@superhost.gr [~/www/cgi-bin]# ls -l /usr/local/apache/logs/suexec_log -rw-rw-r-- 1 nobody nobody 675389 Jun 6 22:05 /usr/local/apache/logs/suexec_log nikos@superhost.gr [~/www/cgi-bin]# ls -l /var/log/httpd/su* -rw-rw-rw- 1 nobody nobody 0 Jun 1 02:52 /var/log/httpd/suexec_log Still same error :(
[toc] | [prev] | [next] | [standalone]
| From | Lele Gaifax <lele@metapensiero.it> |
|---|---|
| Date | 2013-06-06 21:26 +0200 |
| Message-ID | <mailman.2822.1370546766.3114.python-list@python.org> |
| In reply to | #47208 |
Νικόλαος Κούρας <nikos.gr33k@gmail.com> writes: > I have re-enabled 'suexec' and set cgi as default phphandler and then trying: > > print( cookie ) > print( '''Content-type: text/html; charset=utf-8\n''' ) > print( message ) Did you tried running that by a standalone Python interpreter? Did you notice something strange, something like that an empty line is missing between headers and body? ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.
[toc] | [prev] | [next] | [standalone]
| From | Νικόλαος Κούρας <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-06-06 12:30 -0700 |
| Message-ID | <0df486c5-5158-4b85-ad2c-1076367ee815@googlegroups.com> |
| In reply to | #47263 |
Τη Πέμπτη, 6 Ιουνίου 2013 10:26:08 μ.μ. UTC+3, ο χρήστης Lele Gaifax έγραψε: > Did you tried running that by a standalone Python interpreter? Did you > notice something strange, something like that an empty line is missing > between headers and body? No, nothing at all. Two '/n/n' are not required. Months now the way i'm printing headers is by: print( '''Content-type: text/html; charset=utf-8\n''' ) and the scripts owrk correctly in browser and in python interpreter too.
[toc] | [prev] | [next] | [standalone]
| From | Skip Montanaro <skip@pobox.com> |
|---|---|
| Date | 2013-06-06 14:35 -0500 |
| Message-ID | <mailman.2823.1370547317.3114.python-list@python.org> |
| In reply to | #47208 |
> Did you tried running that by a standalone Python interpreter? Did you > notice something strange, something like that an empty line is missing > between headers and body? He will get an extra blank line, since he added a newline character at the end of his Content-Type string. Skip
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.python
csiph-web