Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    debug c cgi script


    hi all,
    i have a html page that calls a c cgi script on my local server;
    how can i view the html page and debug the script at the same time?
    if i would give some input in a form on the html page then i want to debug the script with the entered data.
    my gues was with w3m and gdb but i don't know how its done...

    thanks in advance

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    13,361
    When the web server starts the CGI program, it normally would do a fork/exec. You could replace the C program with a script that has the same calling format, which in turn would start the C program in the debugger. There is a graphical debugger for Linux called Insight, from some folks at Red Hat and Cygnus. Here is a link to it: Insight home page

    Alternatively, you can alter your C program so it does a longish wait after entering main(). At the point it is started, you can attach to it running gdb or whatever, and run it from there setting break points, inspecting variables, etc. You do have to build the program with debugging enabled and don't strip it before running.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    13,361
    BTW, I just downloaded, built, and was able to run Insight. It builds its own version of GDB which may be out of date for my new SL6 (RHEL 6) system and I didn't try to do much other than see if it could be built and run, which it does, though I did have to make one minor fix to the gdb/eval.c file to keep a warning from escalating to an error (use of uninitialized variables - I just needed to memset() two arrays).
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. $spacer_open
    $spacer_close
  5. #4
    thanks for your reply, it seems very complicated but i'll give it a try!
    perhaps you could give me a link to a tutorial or something?

  6. #5
    no, I can and will figure it out!!

  7. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    13,361
    it's not that complicated. I'm sure you'll figure it out. Just beat on it until it surrenders!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #7
    how can i set my environment variable QUERY_STRING from terminal?
    (something like 'setenv QUERY_STRING var1=x&var2=y'??.

    then i can debug my script that way.

  9. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    13,361
    What shell are you using? The standard Linux shell is bash. If that's what you are using, try this:
    Code:
    export QUERY_STRING="var1=x&var2=y"
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  10. #9
    thanks rubberman!

  11. #10
    i must admit; transferring to a linux env for programming is giving me a hard time...even with simple things!
    i also started with python and C cgi programming, coming from C# stand alone app development in Visual Studio you can imagine it isn't easy
    thank god that its just a hobby!!

    how can i avoid using the "%" sign in the css tag when you want to embed html in pyhton
    Last edited by rudie; 03-07-2011 at 02:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •