cgi integration question 2
Ken
ken at hotmail.com
Mon Oct 21 05:24:54 EDT 2002
"Ken" <ken at hotmail.com> wrote in message
news:ap0geu$qgq08$1 at ID-49758.news.dfncis.de...
>
> "Gerhard Häring" <gerhard.haering at gmx.de> wrote in message
> news:mailman.1035154105.10088.python-list at python.org...
> > * Ken <ken at hotmail.com> [2002-10-21 08:02 +1000]:
> > > Hi, there isn't such module call cgitb
> > > Traceback (most recent call last):
> > > File "chessboard.cgi", line 7, in ?
> > > import os, cgi, cgitb
> > > ImportError: No module named cgitb
> >
> > cgitb is available in Python 2.2 and later.
> >
> > > The python code is here:
> > > http://www.ug.cs.usyd.edu.au/~keho/comp3204/chessboard.txt and
> > > http://www.ug.cs.usyd.edu.au/~keho/comp3204/chessboard.cgi
> > >
> > > The C++ test code is here:
> > > http://www.ug.cs.usyd.edu.au/~keho/comp3204/test02.cc
> >
> > Works fine for me if I install it all locally. It prints this:
> >
> > lines: ['12\n', '13\n', '33\n', '31\n', '32\n', '22\n', '21\n', '23\n',
> '11\n']
> > Content-type: text/html results: ['12\n', '13\n', '33\n', '31\n',
'32\n',
> '22\n', '21\n', '23\n', '11\
> > n']
> > +-----------------+
> > | 2 | 8 | 3 |
> > 3 |-----+-----+-----|
> > 2 | 1 | 6 | 5 |
> > 1 |-----+-----+-----|
> > | 9 | 7 | 4 |
> > +-----------------+
> > A B C
> >
> > You might want to fix the print statements so you get something like:
> >
> > Content-type: text/html
> >
> > <html>
> > [...]
> >
> > Note the empty line between the HTTP headers (here only one line, the
> > Content-type line) and the HTTP body.
> >
> > > What did I do wrong to constantly get that broken pipe error?
> > > Traceback (most recent call last): File
> > > "/usr/cs3/keho/lib/html/comp3204/chessboard.cgi", line 143, in ?
> > > outf.close() IOError: [Errno 32] Broken pipe
> >
> > Most probably a permission problem of some sort. I'd copy the C++
> > executable in the same directory as the Python script, but still use the
> > full path in os.popen2 or use "./knight" as a relative path. Also check
> > the permissions are ok (i. e. the user that runs the cgi scripts can
> > execute the C++ executable).
> >
> > -- Gerhard
> >
>
> Hi,
>
> chesslib.printMainHeader("Chessboard") does the content printout, which
> calls:
>
> def printMainHeader(title):
> #Print the status header of the menu screen
> print "Content-type: text/html"
> print ""
> print '<HTML>'
> print '<title>', title, '</title>'
> print '<head><BODY bgcolor="#FFFFFF" text="#000000" link="#000011"
> alink="#000011" vlink="#000011"></body></head>'
>
> I am still getting the stupid broken pipe error, even after I chmod777 to
> all my files, including the c++ executable. : (
>
> The executable is in the same folder as the python script. The path
calling
> "knight" is the absolute path from my uni's account. Unfortunately, I
can't
> install python 2.2 on uni's server..... :(
>
> So......anyone know how I can solve this stupid broken pipe error?
> outf, inf = os.popen2("/n/grey/u6/cs3/keho/lib/html/comp3204/knight")
> print >>outf, size
> print >>outf, startX
> print >>outf, startY
> outf.close() #<< ==== Broken Pipe error on this line
> lines = inf.readlines() #Output produce by back end program ["34", "35",
> ...etc]
>
> Works fine on telnet, works fine on cygwin, just give me a headache on the
> web. : (
>
> Traceback (most recent call last): File
> "/usr/cs3/keho/lib/html/comp3204/chessboard.cgi", line 143, in ?
> outf.close() IOError: [Errno 32] Broken pipe
>
> Thanks in advance
>
More to add..... I reload the script on browser many times. 80% return the
broken pipe error. The other 20% return this
lines: [] Content-type: text/html results: []
which are test print statements I put in to debug. It seems to me
inf.readlines() returns nothing (an empty list) in the 20% that the screen
can load......and the table shown above are all initial 0s, not 1-9.
So, what does this clue give me in solving this problem?
Thanks
More information about the Python-list
mailing list