Is this code correct?

  • Thread starter Íßêïò Ãêñ33ê
  • Start date
Í

Íßêïò Ãêñ33ê

#!/usr/bin/python3
# coding=utf-8

import cgitb; cgitb.enable()
import cgi, os, sys
from http import cookies

# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
nikos = cookie.get('nikos')

# if visitor cookie does exist
if nikos:
msg = "ÁÐÏ ÔÇÍ ÅÐÏÌÅÍÇ ÅÐÉÓÊÅØÇ ÓÏÕ ÈÁ ÓÅ ÕÐÏËÏÃÉÆÙ ÙÓ ÅÐÉÓÊÅÐÔÇ ÁÕÎÁÍÏÍÔÁÓ ÔÏÍ ÌÅÔÑÇÔÇ!"
cookie['nikos'] = 'admin'
cookie['nikos']['path'] = '/'
cookie['nikos']['expires'] = -1 #this cookie will expire now
else:
msg = "ÁÐÏ ÄÙ ÊÁÉ ÓÔÏ ÅÎÇÓ ÄÅÍ ÓÅ ÅÉÄÁ, ÄÅÍ ÓÅ ÎÅÑÙ, ÄÅÍ ÓÅ ÁÊÏÕÓÁ! ÈÁ ÅÉÓÁÉ ÐËÅÏÍ Ï ÁÏÑÁÔÏÓÅÐÉÓÊÅÐÔÇÓ!!"
cookie['nikos'] = 'admin'
cookie['nikos']['path'] = '/'
cookie['nikos']['expires'] = 60*60*24*30*12 #this cookie will expire ina year


#needed line, script does *not* work without it
sys.stdout = os.fdopen(1, 'w', encoding='utf-8')

print( cookie )
print ( "Content-type: text/html; charset=utf-8\n" )
print( msg )

sys.exit(0)
 
Í

Íßêïò Ãêñ33ê

This is my last question, everythign else is taken care of.

i cant test thjis coe online because i receive this

[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml

when i tail -F /usr/local/apache/logs/error_log &

maybe it is correct but it wont run, perhaps somethign with linux?
 
C

Chris Angelico

#!/usr/bin/python3
# coding=utf-8
(chomp a whole lot of code without any indication of what it ought to do)

Why not run it and see? If it does what it ought to, it's correct; if
it does something different, it's not. Why do you expect us to do your
basic testing for you?

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 30 ÌáÀïõ 2013 3:34:09 ì.ì. UTC+3, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
Why not run it and see? If it does what it ought to, it's correct; if

it does something different, it's not. Why do you expect us to do your

basic testing for you?



ChrisA

But i cannot test it locally, i just write the code upload it on my remote server and run it from there. But h=this doenst seem to be a python issue, if it is ill correct it myself, it says somehtign about some suexec....
 
C

Chris Angelico

This is my last question, everythign else is taken care of.

i cant test thjis coe online because i receive this

[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permissiondenied
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml

when i tail -F /usr/local/apache/logs/error_log &

maybe it is correct but it wont run, perhaps somethign with linux?

I don't know, why not ask on a Linux mailing list? Or have you run
them out of patience too?

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 30 ÌáÀïõ 2013 3:59:21 ì.ì. UTC+3, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
This is my last question, everythign else is taken care of.
i cant test thjis coe online because i receive this
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure:could not open log file
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml
when i tail -F /usr/local/apache/logs/error_log &
maybe it is correct but it wont run, perhaps somethign with linux?



I don't know, why not ask on a Linux mailing list? Or have you run

them out of patience too?



ChrisA

I though you guys might know because you "do" linux as well.

i tried chown "nikos:nikos ./koukos.py" but doenst do the job either.
 
M

Mark Lawrence

This is my last question, everythign else is taken care of.

i cant test thjis coe online because i receive this

[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] fopen: Permission denied
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
[Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] File does not exist: /home/nikos/public_html/500.shtml

when i tail -F /usr/local/apache/logs/error_log &

maybe it is correct but it wont run, perhaps somethign with linux?

Please ask questions unrelated to Python on a list that is unrelated to
Python.
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 30 ÌáÀïõ 2013 4:05:00 ì.ì. UTC+3, ï ÷ñÞóôçò Mark Lawrence Ýãñáøå:
Please ask questions unrelated to Python on a list that is unrelated to
Python.

Okey, i will.
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 30 ÌáÀïõ 2013 4:36:11 ì.ì. UTC+3, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
Lemme guess, he's next going to ask on the PostgreSQL mailing list. I
mean, that's unrelated to Python, right?

Well Chris, i'am not that stupid :)

I intend to ask questions unrelated to Python to a list unrelated to Pythonbut related to my subject, whish is 'suexec', that would mean a linux list..
 
C

Cameron Simpson

| Τη Πέμπτη, 30 ΜαÎου 2013 4:36:11 μ.μ. UTC+3, ο χÏήστης Chris Angelico έγÏαψε:
| > Lemme guess, he's next going to ask on the PostgreSQL mailing list. I
| > mean, that's unrelated to Python, right?
|
| Well Chris, i'am not that stupid :)
|
| I intend to ask questions unrelated to Python to a list unrelated to Python but related to my subject, whish is 'suexec', that would mean a linux list.

Actually, you need an apache httpd list for suexec. It is part of
the web server CGI implementation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top