Unicode issue with Python v3.3

nagia.retsina at gmail.com nagia.retsina at gmail.com
Sun Apr 14 07:22:49 EDT 2013


Τη Κυριακή, 14 Απριλίου 2013 12:28:32 μ.μ. UTC+3, ο χρήστης Cameron Simpson έγραψε:
> On 13Apr2013 23:00, nagia.retsina at gmail.com <nagia.retsina at gmail.com> wrote:
> 
> | root at nikos [/home/nikos/public_html/foo-py]# pwd
> 
> | /home/nikos/public_html/foo-py
> 
> | root at nikos [/home/nikos/public_html/foo-py]# cat foo.py 
> 
> | #!/bin/sh
> 
> | exec 2>>/home/nikos/cgi.err.out
> 
> | echo "$0 $*" >&2
> 
> | id >&2
> 
> | env | sort >&2
> 
> | set -x
> 
> | exec /full/path/to/foo-py ${1+"$@"}
> 
> | 
> 
> | root at nikos [/home/nikos/public_html/foo-py]# python3 foo.py 
> 
> |   File "foo.py", line 2
> 
> |     exec 2>>/home/nikos/cgi.err.out
> 
> |          ^
> 
> | SyntaxError: invalid syntax
> 
> 
> 
> That is because foo.py isn't a python script anymore, it is a shell script.
> 
> Its purpose is to divert stderr to a file and to recite various
> 
> things about the environment to that file in addition to any error
> 
> messages.
> 
> 
> 
> Just run it directly:
> 
> 
> 
>   ./foo.py
> 
> 
> 
> The #! line should cause it to be run by the shell.
> 
> 
> 
> I also recommend you try to do all this as your normal user account.
> 
> Root is for administration, such as stopping/starting apache and
> 
> so on. Not test running scripts from the command line; consider:
> 
> if the script has bugs, as root it can do an awful lot of damage.
> 
> 
> 
> | root at nikos [/home/nikos/public_html/foo-py]# 
> 
> | As far as thr tail -f of the error_log:
> 
> | root at nikos [/home/nikos/public_html]# touch /var/log/httpd/error_log
> 
> 
> 
> That won't do you much good; apache has not opened it, and so it
> 
> will not be writing to it. It was writing to a file of that name,
> 
> but you removed that file. Apache probably still has its hooks in the old
> 
> file (which now has no name).
> 
> 
> 
> Restarting apache should open (or create if missing) this file for you.
> 
> 
> 
> | root at nikos [/home/nikos/public_html]# tail -f /var/log/httpd/error_log
> 
> | and its empty even when at the exact same time i run 'python3
> 
> | metrites.py' from another interactive prompt when it supposed to
> 
> | give live feed of the error messages.
> 
> 
> 
> No, _apache_ writes to that file. So only when you visit the web
> 
> page will stuff appear there.
> 
> 
> 
> If you just run things from the command line, error messages will appear on your terminal. Or, after this line of the wrapper script:
> 
> 
> 
>   exec 2>>/home/nikos/cgi.err.out
> 
> 
> 
> the error messages will appear in cgi.err.out.
> 
> 
> 
> | Cameron would it be too much to ask to provide you with root
> 
> | access to my VPS server so you can have a look there too?
> 
> | i can pay you if you like if you wait a few days to gather some money.
> 
> 
> 
> I really do not recommend that:
> 
> 
> 
>   - it is nuts to blithely allow a stranger root access to your system
> 
>   - you won't learn anything about CGI scripts
> 
> 
> 
> What you need for further debugging of your python issues is access
> 
> to the error messages from the CGI script. That is the purpose of
> 
> the wrapper script.
> 
> 
> 
> Get the wrapper running on the command line and then test it via the browser.
> 
> 
> 
> Cheers,
> 
> -- 
> 
> Cameron Simpson <cs at zip.com.au>
> 
> 
> 
> Lord grant me the serenity to accept the things I can not change,
> 
>      the courage to change the things that I can,
> 
> and the wisdom to hide the bodies of those people I had to kill
> 
>      because they pissed me off.
> 
>         - Jeffrey Papen <JPapen at asucla.ucla.edu>

Well i trust you because you are the only one along with Lele that are helpimg me here:

i tried what you said:

root at nikos [/home/nikos/public_html/cgi-bin]# service httpd restart
root at nikos [/home/nikos/public_html/cgi-bin]# python3 metrites.py 
root at nikos [/home/nikos/public_html]# cd foo-py/
root at nikos [/home/nikos/public_html/foo-py]# ls
./  ../  foo.py*
root at nikos [/home/nikos/public_html/foo-py]# ./foo.py 
root at nikos [/home/nikos/public_html/foo-py]# cd ..
root at nikos [/home/nikos/public_html]# cat cgi.err.out 
root at nikos [/home/nikos/public_html/cgi-bin]# cat /var/log/httpd/error_log 
root at nikos [/home/nikos/public_html/cgi-bin]# 

and i have run the script form browser but i still see nothing.

I insist that you will make the most of this if you access the VPS yourself.
it runs CentOS 6.4

Please accept, i trust you.



More information about the Python-list mailing list