1 Reply Latest reply on Jun 2, 2011 7:48 AM by lsharma1064

    debug reg.cgi - how to know the exception detail in try..except

    lsharma1064 Level 1

      after digging more into the app i have found that when i run the http://192.168.0.110/cgi/reg.cgi?&username=shaun&identity=3

      It returns false... which means that the reg.cgi could insert the username and identity inside sqlite db.. my problem is how will i know what error is coming as i dont have working knowledge of cgi script.. below is the code

       

      How to print the type of error in except like in dotnet we have try...catch(Exception ex){ ex.messsage} where ex.message will tell me the error.. how to do this in cgi

       

      print 'Content-type: text/plain\n\n<?xml version="1.0" encoding="utf-8"?>\n<result>'

       

      if user:
          try:
              c = db.cursor()
              c.execute("insert or replace into registrations values (?, ?, datetime('now'))", (user, identity))
              print '\t<update>true</update>'
          except:
              print '\t<update>false</update>'

       

      for f in friends:
          print "\t<friend>\n\t\t<user>%s</user>" % (xml.sax.saxutils.escape(f), )
          c = db.cursor()
          c.execute("select m_username, m_identity from registrations where m_username = ? and m_updatetime > datetime('now', '-1 hour')", (f, ))
          for result in c.fetchall():
              eachIdent = result[1]
              if not eachIdent:
                  eachIdent = ""
              print "\t\t<identity>%s</identity>" % (xml.sax.saxutils.escape(eachIdent), )
              if f != result[0]:
                  print "\t\t<registered>%s</registered>" % (xml.sax.saxutils.escape(result[0]), )
          print "\t</friend>"

       

      db.commit()

       

      print "</result>"