From owner-freebsd-questions@FreeBSD.ORG Sat Oct 10 01:49:26 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E23C91065670 for ; Sat, 10 Oct 2009 01:49:25 +0000 (UTC) (envelope-from mahlerrd@yahoo.com) Received: from web51012.mail.re2.yahoo.com (web51012.mail.re2.yahoo.com [206.190.39.155]) by mx1.freebsd.org (Postfix) with SMTP id 88C948FC17 for ; Sat, 10 Oct 2009 01:49:25 +0000 (UTC) Received: (qmail 76484 invoked by uid 60001); 10 Oct 2009 01:49:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1255139364; bh=EuoIwhVtqkZbc19wjmXDFkxrwB3aFKUkwdzvOi3zeUM=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type; b=o/Nr4enhp8rE4DDYd02XDq7ROohKhTP+DK0qlBEdSWMqAD3dRT7wobilIXjjBUg7WhBeLV5wqWTvP02m77r1OAy7IPTEt8FrQ11F6XBJd+i8ca/a/ibntzDdJK/d7Hc583ySLqPksvRe0MIdI0LcGDgSzmUhSVmtqTj66O0luEE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type; b=Xss5huSxvULA/+UWXbQmJGjUYgThutYY5zSlfRgqw8nhE/DC/Q0R8kmlT3ZTRbaXuqwI9K9Z7AxP44Yp4vB3uuLbRGsUeHAgvC52kh8QJnQ41Vv7bhHzIVjHq85LQDZuTUP+fc2GkcXsjytpJZsRJ17Ewu/Kjb6fioLm9qbQhbY=; Message-ID: <729381.76401.qm@web51012.mail.re2.yahoo.com> X-YMail-OSG: TN1kJXgVM1kEOFaH07gxKqQGPpRYA783CywFNjuQGx1FCANVNQHJLqiHGyp3g_BW2nFReAw6WA_n4k_l.epVRa4cZCCiWmKs_KlnONbQArV4wRYn8Ma_mculS.6ZgEzBlYFmfo3ZQZ_YwZjka1d2vjDnsojOn2MeqOv4VKEXhLcjb5XABnroZbp5kNFRTA3287WNGrz0bOFZZ53xF6UJsjDzc_QPIvhkrK1du052GrhJNz5niP19NxEYmD8yj8TgtHstMXa16fw4BeSFDnL7y6OxJOjfhBGmEXUCbuPywIEfZ7C3fG9oJGvWdgo7VU56wERBcm.d0ywVX6ZNfN.OWCPUXjuyGlX0Pu4VzhGidrUWebvlNpxMAbih0mjkNHlEQuJklJGqZLWUgn.vHxnWptc9mPe7wpGYI3C0sUY- Received: from [71.117.53.27] by web51012.mail.re2.yahoo.com via HTTP; Fri, 09 Oct 2009 18:49:24 PDT X-Mailer: YahooMailClassic/7.0.14 YahooMailWebService/0.7.347.3 Date: Fri, 9 Oct 2009 18:49:24 -0700 (PDT) From: Richard Mahlerwein To: FreeBSD-Questions MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Victor Subervi Subject: Re: Automatic chmod X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: mahlerrd@yahoo.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Oct 2009 01:49:26 -0000 >From: Victor Subervi >Subject: Re: Automatic chmod >To: mahlerrd@yahoo.com, freebsd-questions@freebsd.org >Date: Friday, October 9, 2009, 11:20 AM > >User? I only have one user on this shared server. Here's the code: > >#!/usr/local/bin/python >import cgitb; cgitb.enable() >import MySQLdb >import cgi >import sys,os >sys.path.append(os.getcwd()) >from login import login >user, passwd, db, host =3D login() >form =3D cgi.FieldStorage() >picid =3D int(form['id'].value) >x =3D int(form['x'].value) >pics =3D {1:'pic1',2:'pic2',3:'pic3',4:'pic4',5:'pic5',6:'pic6'} >pic =3D pics[x] >db =3D MySQLdb.connect(host=3Dhost, user=3Duser, passwd=3Dpasswd, db=3Ddb) >cursor=3D db.cursor() >sql =3D "select " + pic + " from productsX where id=3D'" + str(picid) + "'= ;" >cursor.execute(sql) >content =3D cursor.fetchall()[0][0].tostring() >cursor.close() >print '''Content-Type: text/plain >Content-Encoding: base64 >''' >print >print content.encode('base64') I finally got to where I could test this.=A0 I'm no Python expert (in fact,= this was the first time I've touched it), but your code, with heavy modifi= cations to slim it to something that can run on my system, seems to be most= ly OK.=A0 Here's the code I ended up with: ********** #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) user=3D"root" passwd=3D"" db=3D"mysql" host=3D"localhost" form =3D cgi.FieldStorage() db =3D MySQLdb.connect(host=3Dhost, user=3Duser, passwd=3Dpasswd, db=3Ddb) cursor=3D db.cursor() sql =3D "select User from user;" cursor.execute(sql) content =3D cursor.fetchall() cursor.close() print '''Content-Type: text/plain Content-Encoding: base64 ''' print print content ********** That all seems to work as I would expect and gives not unreasonable output.= =A0 Not that I know it's correct or what's needed, but it seems to print wh= at you'd think it would. Can you try running a test script that does, Oh, say, something like the be= low to see if it works?=A0 (AGAIN, I don't know python AND I'm not testing = this, just hand-writing it so excuse my code!) #!/usr/local/bin/python print '''Content-Type: text/plain ''' print "Hopefully this works" At this point, I really haven't much more to go on.=A0 The above may pinpoi= nt what sort of permissions issue it is.=A0 Besides, if it works, you could= slowly add in lines from your previous example until you find the offendin= g line...=20 Also, If you haven't already done so, you may want to try posting in some p= ython help forums or something.=A0 This doesn't have the feel of a FreeBSD = specific problem, so there's bound to be other Python folks who've hit this= and solved it before. =0A=0A=0A