Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: (tye)Re: Debugging a CGI

by toma (Vicar)
on Sep 05, 2001 at 11:47 UTC ( #110234=note: print w/replies, xml ) Need Help??


in reply to (tye)Re: Debugging a CGI
in thread Debugging a CGI

I think I can see where you are headed with this, but I didn't get your example to work yet. Your idea would be especially useful on systems with firewall constraints that do not allow X Window traffic to pass from the web server to the developer's X server.

This is what I tried:
I used telnet to log onto the web server, and made a little cgi program that used your code. I set the TTY variable to be the same as the device used by my telnet window. I used chmod to open up read and write priviledges on the TTY device for the telnet window. I invoked the CGI from my web browser and I saw the prompt for the debugger come up in my telnet window. But when I typed a debugger command, the command went to the shell instead of going to the debugger. So the debugger commands weren't executed, and the CGI program hung.

Suggestions?

It should work perfectly the first time! - toma

Replies are listed 'Best First'.
(tye)Re2: Debugging a CGI
by tye (Sage) on Sep 05, 2001 at 19:39 UTC

    Thanks, toma, for trying this out. You are doing great. Sorry that I forgot about this snag. With both your interactive shell and the Perl debugger trying to read from your tty, the reads will interleave and not match up well with the prompts.

    So your shell wrote out a prompt and then requested a read. Next, the debugger wrote out a prompt and then requested a read. The shell's request for a read was still active and so the next line you type goes to the shell even though what you see is a debugger prompt. The debugger is still waiting for its read to complete so the CGI goes nowhere.

    The simplest solution is to just tell your interactive shell to stop reading from your tty for a while. I'd usually do something like "sleep 6000". Then I could interact with the debugger fine. When done debugging that session, an interupt (usually CTRL-C) would give me back my interactive shell prompt.

    A second telnet session can also be useful so you aren't tempted to try to get your interactive shell prompt back while still debugging. (:

            - tye (but my friends call me "Tye")
      I tried adding the sleep command and your approach worked flawlessly! I was able to single step through my CGI program and see the output get rendered a piece at a time in the web browswer.

      I should also mention that I figured out which TTY device to use running the tty command. In my case, this was pts/0. To open up the permissions on this tty I used chmod 777 /dev/pts/0, and in the cgi program the corresponding line is
      $ENV{PERLDB_OPTS} = 'TTY=/dev/pts/0';

      Using the text-based perl debugger reminded me why I like ptkdb so much! The ptkdb GUI is very intuitive, and I really have to struggle to do simple things in the text-mode debugger. This seems strange to me, since I normally don't have problems with text-based tools. I normally get bored with GUIs quickly and seek a text-based solution.

      Even so, this is a valuable technique, especially for working across firewalls. I wonder if I could also somehow use ssh?

      Thanks tye!

      Update:Changed to a better way of determining which tty to use.

      It should work perfectly the first time! - toma

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://110234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2023-02-07 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (38 votes). Check out past polls.

    Notices?