Τη Σάββατο, 13 Απριλίου 2013 1:28:07 μ.μ. UTC+3, ο χρήστης Cameron Simpson έγραψε: > On 12Apr2013 21:50, nagia.rets...@gmail.com <nagia.rets...@gmail.com> wrote: > > | Ookey after that is corrected, i then tried the plain solution and i got > this response back form the shell: > > | > > | Traceback (most recent call last): > > | File "metrites.py", line 213, in <module> > > | htmldata = f.read() > > | File "/root/.local/lib/python2.7/lib/python3.3/encodings/iso8859_7.py", > line 23, in decode > > | return codecs.charmap_decode(input,self.errors,decoding_table)[0] > > | UnicodeDecodeError: 'charmap' codec can't decode byte 0xae in position 47: > character maps to <undefined> > > | > > | then i switched to: > > | > > | with open('/home/nikos/www/' + page, encoding='utf-8') as f: > > | htmldata = f.read() > > | > > | and i got no error at all, just pure run *from the shell*! > > > > Ok, so you need to specify utf-8 to decode the file. Good. > > > > | But i get internal server error when i try to run the webpage from the > browser(Chrome). > > > > That is standard for a CGI script that does not complete successfully. > > > > | So, can you tell me please where can i find the apache error log so to > display here please? > > > > That depends on the install. Have a look in /var/log/apache or similar. > > Otherwise you need to find the httpd.conf for the apache and look > > for its log coniguration settings. > > > > | Apcher error_log is always better than running 'python3 metrites.py' > because even if the python script has no error apache will also display more > web related things? > > > > The error log is where error messages from CGI scripts go. And other error > messages. > > It is very useful when testing CGI scripts. > > > > Of course, it's best to work out as much as possible from the command > > line first; you have much more direct control and access to errors > > there. That only gets you so far though; the environment the CGI > > script runs in is not the same as your command line, and some > > different behaviour can come from this. > > > > BTW, are you sure python3 is running your CGI script? > > Also, the CGI script may not be running as you, but as the apache user. > > In that case, it may fail if it does not has permission to access various > > files owned by you. > > > > Anyway, you need to see the error messages to work this out. > > > > If you can't find the error log you can divert stderr at the > > start of your python program: > > > > sys.stderr = open('/home/nikos/cgi.err.out', 'a') > > > > and watch that in a shell: > > > > tail -f cgi.err.out > > > > Cheers, > > -- > > Cameron Simpson <c...@zip.com.au> > > > > If you 'aint falling off, you ar'nt going hard enough. - Fred Gassit
root@macgyver [/home/nikos/public_html/cgi-bin]# ls ../cgi.err.out ../cgi.err.out root@macgyver [/home/nikos/public_html/cgi-bin]# cat ../cgi.err.out root@macgyver [/home/nikos/public_html/cgi-bin]# Also i have foudn the error log and i tried to view it but it was empty and then i removed it and then run the script both from shell and broswer but it didnt reappeared. root@macgyver [/home/nikos/public_html/cgi-bin]# cat /var/log/httpd/error_log cat: /var/log/httpd/error_log: No such file or directory root@macgyver [/home/nikos/public_html/cgi-bin]# Maybe its somehtign wron with my enviroment? Should we check the Apache and CGI enviroment somehow and also make sure as you say that *I* run the CGI scripts and not user 'Apache' ? Tell me what commands i should issues please and i will display the output to you. Thank you Cameron, for helpimg me. Somehow the script doesnt seem to be the issue in my VPS. -- http://mail.python.org/mailman/listinfo/python-list