using telnetlib in python to configure a router. i'm using cgi to display the python script to a browser.
i'm having trouble troubleshooting the code because cgi just display's an error screen 'internal server error'
so, i really don't see where i'm making the mistake. i can run the python script through the python interpreter, but that's just a hassle.
any suggestions on how to troubleshoot the output? i've tried using
print "Content-type:text/plain\n" as opposed to "Content-type:text/html\n" so as to just display the unformatted output without html formatting, but i still am not seeing where i'm making mistakes.
i know i can cat /var/log/httpd/error_log
but i guess what i'm asking is if anyone can give me some more specifics about what is actually going on.
i understand this:
telnetlib is a module that'll open a socket to the router or switch. the physical and data link connection we're not going to see, the network layer is addressed by the ip which i have set to a variable and is here
host = "192.168.1.1"
tn = telnetlib.Telnet(HOST, timeout=TIMEOUT)
any further specifics of communication is held within the actual module telnetlib -- socket or transport layer tcp settings.
the server 'sends' the message, encapsulated at what? layer 7 down through layer 2 as the data communications model/osi specifies.. it goes over the wire and over to the client which decapsulates the packet and sends it back up to the telnet application.
i understand i can't see the output of the client(the switch or router) because stdout is defined on the router and it's not the socket that the command came in on, so it has no transport back to the server. it is buffered? in the object?
this is where i'm getting lost
i know i'll eventually use output = tn.read_all() to display the output on the website, but that, at least in part, is failing
i can provide more code. i think these are all fairly standard things to non-newbies like me