Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53060 > unrolled thread

[error] [client 178.59.111.223] (2)No such file or directory: exec of

Started byFerrous Cranus <nikos@superhost.gr>
First post2013-08-27 15:52 +0300
Last post2013-08-29 11:04 +1000
Articles 20 on this page of 42 — 12 participants

Back to article view | Back to comp.lang.python


Contents

  [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos@superhost.gr> - 2013-08-27 15:52 +0300
    Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos@superhost.gr> - 2013-08-27 16:05 +0300
      Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos@superhost.gr> - 2013-08-27 16:35 +0300
        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-27 19:20 -0400
      Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of ishish <ishish@domhain.de> - 2013-08-27 14:59 +0100
        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos@superhost.gr> - 2013-08-27 18:04 +0300
          Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of ishish <ishish@domhain.de> - 2013-08-27 16:22 +0100
            Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 02:48 -0700
              Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of ishish <ishish@domhain.de> - 2013-08-28 11:11 +0100
                Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 03:43 -0700
                  Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 03:46 -0700
                    Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 04:14 -0700
                      Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Dave Angel <davea@davea.name> - 2013-08-28 11:32 +0000
                        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 04:35 -0700
                        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 04:38 -0700
                          Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Dave Angel <davea@davea.name> - 2013-08-28 18:40 +0000
                        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 04:55 -0700
                          Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-08-28 15:38 +0200
                            Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 07:58 -0700
                              RE: [error] [client 178.59.111.223] (2)No such file or directory: exec of "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid> - 2013-08-28 18:44 +0000
                                Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-28 22:49 +0000
                                  Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-28 18:56 -0400
                                    Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-28 23:36 +0000
                              Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Chris Angelico <rosuav@gmail.com> - 2013-08-29 08:55 +1000
                      Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of ishish <ishish@domhain.de> - 2013-08-28 12:51 +0100
                        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 05:03 -0700
                          Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of ishish <ishish@domhain.de> - 2013-08-28 13:16 +0100
                  Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-28 12:21 +0000
                    Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 05:36 -0700
          Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-27 17:07 +0000
            Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 01:46 -0700
              Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 02:24 -0700
              Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-28 12:11 +0000
                Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 05:17 -0700
                  Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-28 12:38 +0000
                    Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 05:48 -0700
                      Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 06:11 -0700
                        Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-28 22:56 +0000
                          Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-08-28 21:20 -0700
                            Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Steven D'Aprano <steve@pearwood.info> - 2013-08-29 06:30 +0000
                      Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Cameron Simpson <cs@zip.com.au> - 2013-08-29 11:01 +1000
                Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of Cameron Simpson <cs@zip.com.au> - 2013-08-29 11:04 +1000

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#53189

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-28 22:49 +0000
Message-ID<521e7e84$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#53178
On Wed, 28 Aug 2013 18:44:28 +0000, Prasad, Ramit wrote:

> Normally I would have thought you would have a public_html or www
> directory in your home folder that would be readable/writable to the web
> server (and where you should write).

I expect that he does. But Nikos has tried writing to the Nikos home 
directory, and to .. (the parent directory). I don't believe he has tried 
writing to . (the current directory), or to /tmp. I'm not an expert, but 
I expect that Apache should be able to write to one of those. And if not, 
he has root on his system, he can simply create a writable directory and 
write to that.

I expect that there are security implications of having a directories 
writable to the webserver user, but temporarily creating one for a quick 
debugging aid should be okay.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53192

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-08-28 18:56 -0400
Message-ID<mailman.330.1377730620.19984.python-list@python.org>
In reply to#53189
On Wed, Aug 28, 2013 at 6:49 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Wed, 28 Aug 2013 18:44:28 +0000, Prasad, Ramit wrote:
>
>> Normally I would have thought you would have a public_html or www
>> directory in your home folder that would be readable/writable to the web
>> server (and where you should write).
>
> I expect that he does. But Nikos has tried writing to the Nikos home
> directory, and to .. (the parent directory). I don't believe he has tried
> writing to . (the current directory), or to /tmp. I'm not an expert, but
> I expect that Apache should be able to write to one of those. And if not,
> he has root on his system, he can simply create a writable directory and
> write to that.
>
> I expect that there are security implications of having a directories
> writable to the webserver user, but temporarily creating one for a quick
> debugging aid should be okay.
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list

This thread follows well travelled grounds from several of the
previous Nikos appearances here.  He seems to have problems grasping
permissions as they relate to apache.  He seems to demand cook book
answers as compared to understanding the issues.  At any rate, isn't
this stuff really something that the Web Server company should be
helping him with?  Its their server, they know how it is configured,
and they can quickly look in his directories to figure out permissions
related issues.

-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#53195

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-28 23:36 +0000
Message-ID<521e8987$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#53192
On Wed, 28 Aug 2013 18:56:56 -0400, Joel Goldstick wrote:

> At any rate, isn't
> this stuff really something that the Web Server company should be
> helping him with?  Its their server, they know how it is configured, and
> they can quickly look in his directories to figure out permissions
> related issues.

Perhaps. But Nikos is reporting that his log file shows entries from all 
the other websites on the server, which doesn't sound good to me. Surely 
any decent, competent web server company would be able to ensure that 
each customer sees only their own log entries?



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53190

FromChris Angelico <rosuav@gmail.com>
Date2013-08-29 08:55 +1000
Message-ID<mailman.329.1377730537.19984.python-list@python.org>
In reply to#53162
On Thu, Aug 29, 2013 at 4:44 AM, Prasad, Ramit
<ramit.prasad@jpmorgan.com.dmarc.invalid> wrote:
> Normally I would have thought you would have a public_html or www directory in your
> home folder that would be readable/writable to the web server (and where you should
> write).

No, a normal setup would have that world-readable but not writable.
That way, even if an exploit is found in your web site that lets an
attacker write files, s/he can't upload more files to the web server's
directory and start running them.

A directory writable by the web server might be /tmp.

ChrisA

[toc] | [prev] | [next] | [standalone]


#53135

Fromishish <ishish@domhain.de>
Date2013-08-28 12:51 +0100
Message-ID<mailman.305.1377690664.19984.python-list@python.org>
In reply to#53128
Am 28.08.2013 12:14, schrieb Ferrous Cranus:
> Okey, continue trying and trying i came up with this:
>
>
> try:
> if os.path.exists( path + page ) or os.path.exists( cgi_path + page 
> ):
> 	cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
> 	data = cur.fetchone()
> except:
> 	with open("err.out", "a") as f:
> 		f.write( repr(query), type(query) )
> 		f.write( repr(escaped_args), type(escaped_args) )
>
>
> But i cannot test it without looking at the error log which is
> scrolling like hell and doesn't even quit with a ctrl+c
>
> How will i manage to troubleshoot?
> Please confirm the above is correct and is what you were propsoing i
> shoudl test.

A simple way I always use if it comes to exception handling:

import sys
import traceback

# Exception Identification
def formatExceptionInfo(maxTBlevel=5):
	cla, exc, trbk = sys.exc_info()
	excName = cla.__name__
	try:
		excArgs = exc.__dict__["args"]
	except KeyError:
		excArgs = "<no args>"
		excTb = traceback.format_tb(trbk, maxTBlevel)
		return (excName, excArgs, excTb)

try:
	# Your code
except:
	print formatExceptionInfo()

[toc] | [prev] | [next] | [standalone]


#53137

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 05:03 -0700
Message-ID<8289446e-2703-4406-8a2f-47622c563978@googlegroups.com>
In reply to#53135
Τη Τετάρτη, 28 Αυγούστου 2013 2:51:03 μ.μ. UTC+3, ο χρήστης ishish έγραψε:
> Am 28.08.2013 12:14, schrieb Ferrous Cranus:
> 
> > Okey, continue trying and trying i came up with this:
> 
> >
> 
> >
> 
> > try:
> 
> > if os.path.exists( path + page ) or os.path.exists( cgi_path + page 
> 
> > ):
> 
> > 	cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
> 
> > 	data = cur.fetchone()
> 
> > except:
> 
> > 	with open("err.out", "a") as f:
> 
> > 		f.write( repr(query), type(query) )
> 
> > 		f.write( repr(escaped_args), type(escaped_args) )
> 
> >
> 
> >
> 
> > But i cannot test it without looking at the error log which is
> 
> > scrolling like hell and doesn't even quit with a ctrl+c
> 
> >
> 
> > How will i manage to troubleshoot?
> 
> > Please confirm the above is correct and is what you were propsoing i
> 
> > shoudl test.
> 
> 
> 
> A simple way I always use if it comes to exception handling:
> 
> 
> 
> import sys
> 
> import traceback
> 
> 
> 
> # Exception Identification
> 
> def formatExceptionInfo(maxTBlevel=5):
> 
> 	cla, exc, trbk = sys.exc_info()
> 
> 	excName = cla.__name__
> 
> 	try:
> 
> 		excArgs = exc.__dict__["args"]
> 
> 	except KeyError:
> 
> 		excArgs = "<no args>"
> 
> 		excTb = traceback.format_tb(trbk, maxTBlevel)
> 
> 		return (excName, excArgs, excTb)
> 
> 
> 
> try:
> 
> 	# Your code
> 
> except:
> 
> 	print formatExceptionInfo()

nikos@superhost.gr [~/www]# [Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] malformed header from script. Bad header=<class 'str'> 'index.html': metrites.py
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] Error in sys.excepthook:
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] ValueError: underlying buffer has been detached
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120]
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] Original exception was:
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] Traceback (most recent call last):
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 191, in <module>
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120]     if not data:
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] NameError: name 'data' is not defined
[Wed Aug 28 12:02:53 2013] [error] [client 108.162.231.120] File does not exist: /home/nikos/public_html/500.shtml

[toc] | [prev] | [next] | [standalone]


#53140

Fromishish <ishish@domhain.de>
Date2013-08-28 13:16 +0100
Message-ID<mailman.306.1377692178.19984.python-list@python.org>
In reply to#53137
Well there you have it:

   File "/home/nikos/public_html/cgi-bin/metrites.py", line 191, in 
<module>
     if not data:
NameError: name 'data' is not defined

[toc] | [prev] | [next] | [standalone]


#53142

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-28 12:21 +0000
Message-ID<521deb44$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#53123
On Wed, 28 Aug 2013 03:43:08 -0700, Ferrous Cranus wrote:

> but i cannot see the error_log because of constant scrolling of error
> output.

Then don't use "tail -F", use "less".

Or try "tail -s 60 -F" which will update only every 60 seconds.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53144

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 05:36 -0700
Message-ID<59c28319-f3ef-4204-9e1a-63b9a0af1a7c@googlegroups.com>
In reply to#53142
Τη Τετάρτη, 28 Αυγούστου 2013 3:21:25 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε:
> On Wed, 28 Aug 2013 03:43:08 -0700, Ferrous Cranus wrote:
> 
> 
> 
> > but i cannot see the error_log because of constant scrolling of error
> 
> > output.
> 
> 
> 
> Then don't use "tail -F", use "less".
> 
> 
> 
> Or try "tail -s 60 -F" which will update only every 60 seconds.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Very nice idea, than k you steven. Less work withiut scrilling like hell liek tail -F did.

this is what i have now:


# Exception Identification 
def formatExceptionInfo(maxTBlevel=5): 
        cla, exc, trbk = sys.exc_info() 
        excName = cla.__name__ 
        try: 
                excArgs = exc.__dict__["args"] 
        except KeyError: 
                excArgs = "<no args>" 
                excTb = traceback.format_tb(trbk, maxTBlevel) 
                return (excName, excArgs, excTb) 

try:
#find the needed counter for the page URL
        if os.path.exists( path + page ) or os.path.exists( cgi_path + page ):
	cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
	data = cur.fetchone()		#URL is unique, so should only be one
except:
        print( formatExceptionInfo() )

i see no error on what it used ot be isnteait comain at the follwing line which is:

		if not data:
			#first time for page; primary key is automatic, hit is defaulted
			cur.execute('''INSERT INTO counters (url) VALUES (%s)''', page )
			cID = cur.lastrowid        #get the primary key value of the new record 
		else:
			#found the page, save primary key and use it to issue hit UPDATE 
			cID = data[0]
			cur.execute('''UPDATE counters SET hits = hits + 1 WHERE ID = %s''', cID )


i jst dont follow..... What ishsi proposed supposed to give us the error in the query bit now it tells difefrent things.

shoudl i remove the function since it want any helopfull?

[toc] | [prev] | [next] | [standalone]


#53078

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-27 17:07 +0000
Message-ID<521cdce7$0$29986$c3e8da3$5496439d@news.astraweb.com>
In reply to#53072
On Tue, 27 Aug 2013 18:04:23 +0300, Ferrous Cranus wrote:

> So, in this line:
> 
> cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
> 
> the variable 'page' needs conversion to what?

You tell us. You want to be a programmer, *you* need to do the 
programming, and not just keep asking others to solve every single bug. 
You have been given all the clues to solve this problem. Start by 
checking what the type of 'page' is, then decide what it ought to be.

Hint: you can use

"print(type(page), file=open('path/to/some/file', 'w'))" 

to see the type of the variable 'page' without displaying it on your 
website.



> all that is stores is the location of a file
> 
> path = '/home/nikos/public_html/'
> page = form.getvalue('page')

And what result does form.getvalue return?

What is its type? Is it a list, a tuple, a dict, a bytes object, a float, 
a str object, something else? DON'T GUESS, and don't assume, find out for 
sure, by inspecting the result.


> if not page and os.path.exists( file ):
> 	# it is an html template
> 	page = file.replace( path, '' )
> 
> So chnage it to what?

What do you think you need to change it to? Pick one:


1) bytes
2) an integer
3) a string
4) a list of floats
5) something else



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53116

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 01:46 -0700
Message-ID<3d299421-7c03-4c92-b860-15b111e75bc1@googlegroups.com>
In reply to#53078
Τη Τρίτη, 27 Αυγούστου 2013 8:07:52 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε:
> On Tue, 27 Aug 2013 18:04:23 +0300, Ferrous Cranus wrote:
> 
> 
> 
> > So, in this line:
> 
> > 
> 
> > cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
> 
> > 
> 
> > the variable 'page' needs conversion to what?
> 
> 
> 
> You tell us. You want to be a programmer, *you* need to do the 
> 
> programming, and not just keep asking others to solve every single bug. 
> 
> You have been given all the clues to solve this problem. Start by 
> 
> checking what the type of 'page' is, then decide what it ought to be.
> 
> 
> 
> Hint: you can use
> 
> 
> 
> "print(type(page), file=open('path/to/some/file', 'w'))" 
> 
> 
> 
> to see the type of the variable 'page' without displaying it on your 
> 
> website.
> 
> 
> 
> 
> 
> 
> 
> > all that is stores is the location of a file
> 
> > 
> 
> > path = '/home/nikos/public_html/'
> 
> > page = form.getvalue('page')
> 
> 
> 
> And what result does form.getvalue return?
> 
> 
> 
> What is its type? Is it a list, a tuple, a dict, a bytes object, a float, 
> 
> a str object, something else? DON'T GUESS, and don't assume, find out for 
> 
> sure, by inspecting the result.
> 
> 
> 
> 
> 
> > if not page and os.path.exists( file ):
> 
> > 	# it is an html template
> 
> > 	page = file.replace( path, '' )
> 
> > 
> 
> > So chnage it to what?
> 
> 
> 
> What do you think you need to change it to? Pick one:
> 
> 
> 
> 
> 
> 1) bytes
> 
> 2) an integer
> 
> 3) a string
> 
> 4) a list of floats
> 
> 5) something else
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Hello Steven,

i tried to do what you said and iam receing this:

[Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120] Original exception was:
[Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120] Traceback (most recent call last):
[Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 39, in <module>
[Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120]     print( type(page), file=open('../err.out', 'w') )
[Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120] PermissionError: [Errno 13] \\u0386\\u03c1\\u03bd\\u03b7\\u03c3\\u03b7 \\u03c0\\u03c1\\u03cc\\u03c3\\u03b2\\u03b1\\u03c3\\u03b7\\u03c2: '../err.out'
[Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120] Premature end of script headers: metrites.py



Also many times when i try to view the error_log by

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

i get realtime scrolling of other joomla webistes pho errors and i have hard time trackign my own webistes erros.

is ther a work around for that?

[toc] | [prev] | [next] | [standalone]


#53119

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 02:24 -0700
Message-ID<25c8e290-b2cd-4138-9634-04b6dca1cd46@googlegroups.com>
In reply to#53116
In my attemtpt to be shwon only mesages pertaining to superhost.gr i try:

alias err='tail -F /usr/local/apache/logs/error_log | grep nikos &'

but now it only displays to me the lines that have '/home/nikos' within them and not all the relevant error lines.

[toc] | [prev] | [next] | [standalone]


#53139

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-28 12:11 +0000
Message-ID<521de8db$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#53116
On Wed, 28 Aug 2013 01:46:01 -0700, Ferrous Cranus wrote:

> Τη Τρίτη, 27 Αυγούστου 2013 8:07:52 μ.μ. UTC+3, ο χρήστης Steven
> D'Aprano έγραψε:

>> Hint: you can use
>> "print(type(page), file=open('path/to/some/file', 'w'))"
>> 
>> to see the type of the variable 'page' without displaying it on your
>> website.


> i tried to do what you said and iam receing this:
> 
> [Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120] Original
> exception was: [Wed Aug 28 08:43:31 2013] [error] [client
> 108.162.231.120] Traceback (most recent call last): [Wed Aug 28 08:43:31
> 2013] [error] [client 108.162.231.120]   File
> "/home/nikos/public_html/cgi-bin/metrites.py", line 39, in <module> [Wed
> Aug 28 08:43:31 2013] [error] [client 108.162.231.120]     print(
> type(page), file=open('../err.out', 'w') ) [Wed Aug 28 08:43:31 2013]
> [error] [client 108.162.231.120] PermissionError: [Errno 13]
> \\u0386\\u03c1\\u03bd\\u03b7\\u03c3\\u03b7
> \\u03c0\\u03c1\\u03cc\\u03c3\\u03b2\\u03b1\\u03c3\\u03b7\\u03c2:
> '../err.out' [Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120]
> Premature end of script headers: metrites.py

Then pick a different location, one where you have permission to write 
files!

Honestly Nikos, I'm not trying to be rude, but if you cannot think of 
this on your own after all this time we've been helping you, perhaps 
programming is not the right vocation for you. Perhaps you need to 
consider a change of career.

If you do decide to stay as a web developer, you need to start thinking:

* What is this error message telling me? ("Permission denied")

* How can I fix that? ("I need permission to read the file. Maybe try a 
different file?")



> Also many times when i try to view the error_log by
> 
> tail -F /usr/local/apache/logs/error_log &
> 
> i get realtime scrolling of other joomla webistes pho errors and i have
> hard time trackign my own webistes erros.
> 
> is ther a work around for that?


That's an apache logging issue, not Python, and I don't know enough about 
apache to do more than guess that there probably is a solution but I have 
no idea what it is.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53141

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 05:17 -0700
Message-ID<bad26a85-e9d7-4e85-a4aa-e5ff8b7f8c4b@googlegroups.com>
In reply to#53139
Τη Τετάρτη, 28 Αυγούστου 2013 3:11:07 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε:
> On Wed, 28 Aug 2013 01:46:01 -0700, Ferrous Cranus wrote:
> 
> 
> 
> > Τη Τρίτη, 27 Αυγούστου 2013 8:07:52 μ.μ. UTC+3, ο χρήστης Steven
> 
> > D'Aprano έγραψε:
> 
> 
> 
> >> Hint: you can use
> 
> >> "print(type(page), file=open('path/to/some/file', 'w'))"
> 
> >> 
> 
> >> to see the type of the variable 'page' without displaying it on your
> 
> >> website.
> 
> 
> 
> 
> 
> > i tried to do what you said and iam receing this:
> 
> > 
> 
> > [Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120] Original
> 
> > exception was: [Wed Aug 28 08:43:31 2013] [error] [client
> 
> > 108.162.231.120] Traceback (most recent call last): [Wed Aug 28 08:43:31
> 
> > 2013] [error] [client 108.162.231.120]   File
> 
> > "/home/nikos/public_html/cgi-bin/metrites.py", line 39, in <module> [Wed
> 
> > Aug 28 08:43:31 2013] [error] [client 108.162.231.120]     print(
> 
> > type(page), file=open('../err.out', 'w') ) [Wed Aug 28 08:43:31 2013]
> 
> > [error] [client 108.162.231.120] PermissionError: [Errno 13]
> 
> > \\u0386\\u03c1\\u03bd\\u03b7\\u03c3\\u03b7
> 
> > \\u03c0\\u03c1\\u03cc\\u03c3\\u03b2\\u03b1\\u03c3\\u03b7\\u03c2:
> 
> > '../err.out' [Wed Aug 28 08:43:31 2013] [error] [client 108.162.231.120]
> 
> > Premature end of script headers: metrites.py
> 
> 
> 
> Then pick a different location, one where you have permission to write 
> 
> files!
> 
> 
> 
> Honestly Nikos, I'm not trying to be rude, but if you cannot think of 
> 
> this on your own after all this time we've been helping you, perhaps 
> 
> programming is not the right vocation for you. Perhaps you need to 
> 
> consider a change of career.
> 
> 
> 
> If you do decide to stay as a web developer, you need to start thinking:
> 
> 
> 
> * What is this error message telling me? ("Permission denied")
> 
> 
> 
> * How can I fix that? ("I need permission to read the file. Maybe try a 
> 
> different file?")
> 
> 
> 
> 
> 
> 
> 
> > Also many times when i try to view the error_log by
> 
> > 
> 
> > tail -F /usr/local/apache/logs/error_log &
> 
> > 
> 
> > i get realtime scrolling of other joomla webistes pho errors and i have
> 
> > hard time trackign my own webistes erros.
> 
> > 
> 
> > is ther a work around for that?
> 
> 
> 
> 
> 
> That's an apache logging issue, not Python, and I don't know enough about 
> 
> apache to do more than guess that there probably is a solution but I have 
> 
> no idea what it is.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

As i have pointed out i as the owner of the accoutn have read and write perimssion bot at www/ and www/cgi-bin
i also chnage the filename and still cant write to the file.

if you as experts cannot help resolve this, how me as a newbiw can?

[toc] | [prev] | [next] | [standalone]


#53146

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-28 12:38 +0000
Message-ID<521def33$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#53141
On Wed, 28 Aug 2013 05:17:34 -0700, Ferrous Cranus wrote:

> As i have pointed out i as the owner of the accoutn have read and write
> perimssion bot at www/ and www/cgi-bin i also chnage the filename and
> still cant write to the file.

If you type filenames as carelessly as you type requests for help, who 
knows what file name you are actually trying to open?

Or to put it another way...

If yuo tpye filnaems as carlesl yas y outype reqets for help, woh knwos 
wha tfile nmae oyu ar eactaly tying to oep n?


Nikos, my Greek is completely non-existent, and I admire you for learning 
a second language. I know your English is good, because I have seen you 
write fluent, excellent English. But if you can't be bothered to type 
carefully and clearly when asking questions, then how can you expect 
others to be bothered to read and respond to your questions?


> if you as experts cannot help resolve this, how me as a newbiw can?

Just because your account has write permission to a location doesn't mean 
that the script being run by the webserver has write permission. You need 
to write to a location where the script has permission to write. First 
you need to find out what account the script is being run under -- it may 
be "apache", or possible "nobody", but I don't know. It shouldn't be 
"root", and almost certainly isn't "nikos". I'm not an expert, but a few 
seconds googling came up with a lot of useful looking hits. Google on 
"what user does apache run as" and do your research.

This is off-topic though. This is not a "beginner's guide to apache" 
forum, if you can't solve this problem yourself you'll have to take it 
elsewhere.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53148

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 05:48 -0700
Message-ID<9fc603a0-6ab9-4c05-b3df-86f07f09fa52@googlegroups.com>
In reply to#53146
Τη Τετάρτη, 28 Αυγούστου 2013 3:38:11 μ.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε:
> On Wed, 28 Aug 2013 05:17:34 -0700, Ferrous Cranus wrote:
> 
> 
> 
> > As i have pointed out i as the owner of the accoutn have read and write
> 
> > perimssion bot at www/ and www/cgi-bin i also chnage the filename and
> 
> > still cant write to the file.
> 
> 
> 
> If you type filenames as carelessly as you type requests for help, who 
> 
> knows what file name you are actually trying to open?
> 
> 
> 
> Or to put it another way...
> 
> 
> 
> If yuo tpye filnaems as carlesl yas y outype reqets for help, woh knwos 
> 
> wha tfile nmae oyu ar eactaly tying to oep n?
> 
> 
> 
> 
> 
> Nikos, my Greek is completely non-existent, and I admire you for learning 
> 
> a second language. I know your English is good, because I have seen you 
> 
> write fluent, excellent English. But if you can't be bothered to type 
> 
> carefully and clearly when asking questions, then how can you expect 
> 
> others to be bothered to read and respond to your questions?
> 
> 
> 
> 
> 
> > if you as experts cannot help resolve this, how me as a newbiw can?
> 
> 
> 
> Just because your account has write permission to a location doesn't mean 
> 
> that the script being run by the webserver has write permission. You need 
> 
> to write to a location where the script has permission to write. First 
> 
> you need to find out what account the script is being run under -- it may 
> 
> be "apache", or possible "nobody", but I don't know. It shouldn't be 
> 
> "root", and almost certainly isn't "nikos". I'm not an expert, but a few 
> 
> seconds googling came up with a lot of useful looking hits. Google on 
> 
> "what user does apache run as" and do your research.
> 
> 
> 
> This is off-topic though. This is not a "beginner's guide to apache" 
> 
> forum, if you can't solve this problem yourself you'll have to take it 
> 
> elsewhere.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

Hi steven , sorry for the typos.

you are write my script is invoked by apache web server application which it runs under account 'nobody'

Here is proof of that:

nikos@superhost.gr [~]# ps aux | grep Apache
nikos     8531  0.0  0.0   6372   680 pts/0    R+   12:44   0:00 grep Apache
nikos@superhost.gr [~]# ps aux | grep apache
root      1101  0.0  0.2  65576  4168 ?        Ss   08:30   0:01 /usr/local/apache/bin/httpd -k start -DSSL
root      8448  0.0  0.1  65576  1700 ?        S    12:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8449  0.0  0.2  65712  3228 ?        S    12:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8450  0.0  0.2  65848  3348 ?        S    12:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8451  0.0  0.2  65848  3360 ?        S    12:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8452  0.0  0.2  65712  3340 ?        S    12:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8453  0.0  0.2  65712  3260 ?        S    12:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8467  0.0  0.1  65712  2356 ?        S    12:43   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8468  0.0  0.1  65712  2344 ?        S    12:43   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody    8519  0.0  0.1  65712  2344 ?        S    12:43   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nikos     8537  0.0  0.0   6372   684 pts/0    R+   12:44   0:00 grep apache

My script were all workign in the previous VPS enviroment, the script is correct is just a few minor thing in the new VPS env that they need to be taken care of thus prohibit my script to run..

please don't give up helping me and tell me please what you want me to try.
tahnk you very much.

[toc] | [prev] | [next] | [standalone]


#53153

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 06:11 -0700
Message-ID<8d949d1b-9b92-44e8-9d16-ff7d9e5a3b2c@googlegroups.com>
In reply to#53148
This si what iam tryign now since the function ishish proposed wont help me.


try:
  #find the needed counter for the page URL
  if os.path.exists( path + page ) or os.path.exists( cgi_path + page ):
      cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
      data = cur.fetchone()		#URL is unique, so should only be one
except:
  print( repr(e) )


[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] Original exception was:
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] Traceback (most recent call last):
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 174, in <module>
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]     cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]   File "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", line 108, in execute
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]     query = query % escaped_args
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] TypeError: unsupported operand type(s) for %: 'bytes' and 'str'
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] 
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] During handling of the above exception, another exception occurred:
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] 
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] Traceback (most recent call last):
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 177, in <module>
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]     print( repr(e) )
[Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] NameError: name 'e' is not defined

[toc] | [prev] | [next] | [standalone]


#53191

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-08-28 22:56 +0000
Message-ID<521e8037$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#53153
On Wed, 28 Aug 2013 06:11:13 -0700, Ferrous Cranus wrote:

> This si what iam tryign now since the function ishish proposed wont help
> me.

I see that your apology for careless writing didn't last very long.

[...]
> except:
>   print( repr(e) )

What is the value of "e" here, and where is it defined?

Let's look at the error in your log file:


> [Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]     print(
> repr(e) ) [Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]
> NameError: name 'e' is not defined


Did you bother to read the error before asking for help?

Variable 'e' is not defined. Perhaps you should define it?


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#53212

FromFerrous Cranus <nikos.gr33k@gmail.com>
Date2013-08-28 21:20 -0700
Message-ID<7309054c-5af6-401c-8d1b-ebea48cb6c0a@googlegroups.com>
In reply to#53191
Τη Πέμπτη, 29 Αυγούστου 2013 1:56:55 π.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε:
> On Wed, 28 Aug 2013 06:11:13 -0700, Ferrous Cranus wrote:
> 
> 
> 
> > This si what iam tryign now since the function ishish proposed wont help
> 
> > me.
> 
> 
> 
> I see that your apology for careless writing didn't last very long.
> 
> 
> 
> [...]
> 
> > except:
> 
> >   print( repr(e) )
> 
> 
> 
> What is the value of "e" here, and where is it defined?
> 
> 
> 
> Let's look at the error in your log file:
> 
> 
> 
> 
> 
> > [Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]     print(
> 
> > repr(e) ) [Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120]
> 
> > NameError: name 'e' is not defined
> 
> 
> 
> 
> 
> Did you bother to read the error before asking for help?
> 
> 
> 
> Variable 'e' is not defined. Perhaps you should define it?

Yes indeed , that was a a syntax error by me:

try:
    #find the needed counter for the page URL
    if os.path.exists( path + page ) or os.path.exists( cgi_path + page ):
    cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
    data = cur.fetchone()        #URL is unique, so should only be one
except Exception as e:
        con.rollback()        #something failed, rollback the entire transaction
        print( repr(e) )

outputs:
[Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 206, in <module>
[Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127]     cur.execute('''SELECT hits FROM counters WHERE url = %s''', page )
[Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127]   File "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", line 108, in execute
[Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127]     query = query % escaped_args

[Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154]   File "/home/nikos/public_html/cgi-bin/metrites.py", line 206, in <module>
[Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154]     cur.execute('''SELECT hits FROM counters WHERE url = %s''', page )
[Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154]   File "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", line 108, in execute
[Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154]     query = query % escaped_args
[Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154] TypeError: unsupported operand type(s) for %: 'bytes' and 'str'


Now at least 'superhost.gr' displays the error when one by browser http://superhost.gr

[toc] | [prev] | [next] | [standalone]


#53217

FromSteven D'Aprano <steve@pearwood.info>
Date2013-08-29 06:30 +0000
Message-ID<521eea9c$0$2743$c3e8da3$76491128@news.astraweb.com>
In reply to#53212
On Wed, 28 Aug 2013 21:20:01 -0700, Ferrous Cranus wrote:

> [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127]   
> File "/home/nikos/public_html/cgi-bin/metrites.py", line 206, in 
> <module>
> [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127]
> cur.execute('''SELECT hits FROM counters WHERE url = %s''', page )
[...]
> TypeError: unsupported operand type(s) for %: 'bytes' and 'str'

Oh look, it's exactly the same error you started with. Congratulations, 
you've made exactly no progress. As I asked you yesterday:

    And what result does form.getvalue return?

    What is its type? Is it a list, a tuple, a dict, a bytes object,
    a float, a str object, something else?


Have you worked that out yet? If you can't work it out, you can guess, 
and then test your guess:


page = form.getvalue('page')
if isinstance(page, list):
     raise TypeError('guessed it was a list, it is a list')


If your guess is wrong, try another guess. Keep going until you work out 
what type page is.

If you can't write to a data file, you can write to the error log:


page = form.getvalue('page')
raise TypeError('type of page is %r' % type(page))


Keep going until you find out what type of data the variable 'page' is 
holding. Now read the error message again:

unsupported operand type(s) for %: 'bytes' and 'str'


Do you understand what that error means? Here is a hint: start a Python 
interactive session, and try things for yourself:


steve@runes:~$ python3.3
Python 3.3.0rc3 (default, Sep 27 2012, 18:31:58) 
[GCC 4.4.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
py>
py> 'string%s' % 'string'
'stringstring'
py> 
py> b'bytes%s' % b'bytes'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes'


Do you see a pattern yet? What do you think will happen if you run this?


b'bytes%s' % 'string'


Try it and see for yourself.


Now look at the error message you are getting. Is it the same error 
message? Do you think that perhaps it has the same cause? How do you 
think you might solve this problem?

Hint: if you have a data item that is type A, and you need it to be type 
B, you need to convert from A to B.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.python


csiph-web