NSLU2-Linux
view · edit · print · history

HowTo.CompilingCGIProgramsForHttpd History

Hide minor edits - Show changes to markup

May 09, 2008, at 01:25 AM by mwester -- despam
Changed lines 1-72 from:

Just Look At This For a secondLoved the Comprehensive work. impressive [LINK=http://ba-free-ca.150m.com/index1.html]1985 diagram free toyota wire[/LINK] <a href=" http://ba-free-ca.150m.com/index1.html ">1985 diagram free toyota wire</a>

to:

Goal:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Prerequisites:

Installation of Unslung.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Steps:

Note: The locations used in this example may vary for your installation.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>
    #include <time.h>

    int main()
    {
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
	       "</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi
    strip webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /home/www/

4) Identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) Access the CGI file through a browser using:

     http://www.ByteRed.com/webhello.cgi

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

May 06, 2008, at 11:52 AM by RXPKW -- TBhPCplIlVpUVzMd
Changed lines 1-72 from:

Goal:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Prerequisites:

Installation of Unslung.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Steps:

Note: The locations used in this example may vary for your installation.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>
    #include <time.h>

    int main()
    {
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
	       "</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi
    strip webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /home/www/

4) Identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) Access the CGI file through a browser using:

     http://www.ByteRed.com/webhello.cgi

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

to:

Just Look At This For a secondLoved the Comprehensive work. impressive [LINK=http://ba-free-ca.150m.com/index1.html]1985 diagram free toyota wire[/LINK] <a href=" http://ba-free-ca.150m.com/index1.html ">1985 diagram free toyota wire</a>

May 06, 2008, at 11:22 AM by MK -- restored spam
Changed lines 1-2 from:

I really Liked This Site, Check itYou Must Look In This Website [LINK=http://freeazg.110mb.com/]120t code free motorola ringtone[/LINK] <a href=" http://freeazg.110mb.com/ ">120t code free motorola ringtone</a>

to:

Goal:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Prerequisites:

Installation of Unslung.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Steps:

Note: The locations used in this example may vary for your installation.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>
    #include <time.h>

    int main()
    {
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
	       "</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi
    strip webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /home/www/

4) Identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) Access the CGI file through a browser using:

     http://www.ByteRed.com/webhello.cgi

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

May 05, 2008, at 10:15 PM by UXAOX -- FYOlAmaH
Changed lines 1-72 from:

Goal:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Prerequisites:

Installation of Unslung.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Steps:

Note: The locations used in this example may vary for your installation.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>
    #include <time.h>

    int main()
    {
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
	       "</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi
    strip webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /home/www/

4) Identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) Access the CGI file through a browser using:

     http://www.ByteRed.com/webhello.cgi

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

to:

I really Liked This Site, Check itYou Must Look In This Website [LINK=http://freeazg.110mb.com/]120t code free motorola ringtone[/LINK] <a href=" http://freeazg.110mb.com/ ">120t code free motorola ringtone</a>

May 05, 2008, at 09:16 PM by fixer -- undoing spam
Changed lines 1-2 from:

Please Review This Site, You'll Like It [LINK= http://freeaza.110mb.com/ ]lorazepam wikipedia the free encyclopedia[/LINK] <a href=" http://freeaza.110mb.com/ ">lorazepam wikipedia the free encyclopedia</a>

to:

Goal:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Prerequisites:

Installation of Unslung.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Steps:

Note: The locations used in this example may vary for your installation.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>
    #include <time.h>

    int main()
    {
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
	       "</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi
    strip webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /home/www/

4) Identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) Access the CGI file through a browser using:

     http://www.ByteRed.com/webhello.cgi

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

May 04, 2008, at 07:33 AM by ZluZm -- KuCfQNFJc
Changed lines 1-72 from:

Goal:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Prerequisites:

Installation of Unslung.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Steps:

Note: The locations used in this example may vary for your installation.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>
    #include <time.h>

    int main()
    {
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
	       "</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi
    strip webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /home/www/

4) Identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) Access the CGI file through a browser using:

     http://www.ByteRed.com/webhello.cgi

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

to:

Please Review This Site, You'll Like It [LINK= http://freeaza.110mb.com/ ]lorazepam wikipedia the free encyclopedia[/LINK] <a href=" http://freeaza.110mb.com/ ">lorazepam wikipedia the free encyclopedia</a>

February 20, 2005, at 12:58 PM by tino --
Changed lines 61-72 from:

That's it!

to:

That's it!

6) Final Note:

For simple CGI scripts, you can use a shell script like following:

 #!/bin/ash
 echo "Content-type: text/plain"
 echo ""
 echo "Hello World!"
 set

Don't forget to chmod +x scriptname.cgi
(Tested with Main.LinksysR29 Linksys R29 Firmware? - the webserver pages are at /home/httpd/html/Management/ in the ramdisk - so it shall work on Unslung.HomePage, too.)

November 17, 2004, at 06:49 PM by tman --
Changed line 17 from:
    #incluce <time.h>
to:
    #include <time.h>
November 17, 2004, at 04:06 AM by michaelebrownmindspringcom --
Changed line 59 from:
     http://www.byteyellow.com/webhello.cgi
to:
     http://www.ByteRed.com/webhello.cgi
November 11, 2004, at 06:18 AM by michaelebrownmindspringcom --
Added line 17:
    #incluce <time.h>
Changed lines 21-23 from:
        printf("Content-type: text/html\n"   /* Necessary for page header */
to:
        time_t tim = time(NULL);

        printf("Content-type: text/html\n"   /* Necessary to specify the type */
Changed lines 27-28 from:
	       "Hello, World!\n"             /* Do the hello thing... */
	       "</body>\n"
to:
	       "Hello, World!<br>\n");       /* Do the hello thing... */

        /* Print out the current time */
        printf("The time is %s<br>\n", asctime(localtime(&tim)) );

	printf("</body>\n"
Added line 34:
November 11, 2004, at 06:17 AM by michaelebrownmindspringcom --
Changed line 19 from:
    main()
to:
    int main()
November 11, 2004, at 06:10 AM by michaelebrownmindspringcom --
Changed lines 20-34 from:
	/* Necessary for page header */
	printf("Content-type: text/html\n");
	printf("\n");  /* This blank line is critical! */

	/* Here is the simplest starting HTML */
	printf("<html>\n");
	printf("<body>\n");

	/* Your HTML goes here */
	printf("Hello, World!\n");

	/* and the simplest ending HTML */
	printf("</body>\n");
	printf("</html>\n");
to:
        printf("Content-type: text/html\n"   /* Necessary for page header */
	       "\n"                          /* This blank line is critical! */
	       "<html>\n"
	       "<body>\n"
	       "Hello, World!\n"             /* Do the hello thing... */
	       "</body>\n"
	       "</html>\n");
November 08, 2004, at 07:00 AM by michaelebrownmindspringcom --
Added line 41:
    strip webhello.cgi
November 08, 2004, at 06:40 AM by michaelebrownmindspringcom --
Changed line 44 from:
    mv webhello.cgi /share/udd/www/
to:
    mv webhello.cgi /home/www/
November 08, 2004, at 06:31 AM by michaelebrownmindspringcom --
Changed line 58 from:
    http://www.nslu2.com/webhello.cgi
to:
     http://www.byteyellow.com/webhello.cgi
November 08, 2004, at 06:30 AM by michaelebrownmindspringcom --
Changed line 12 from:

Here's the Hello program turned into a CGI executable for thttpd.

to:

Note: The locations used in this example may vary for your installation.

November 08, 2004, at 06:29 AM by michaelebrownmindspringcom --
Changed line 3 from:

Compile a C program to make a CGI executable for thttpd.

to:

Compile a C program to make a CGI executable for thttpd - all on the NSLU2.

Changed line 8 from:

Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2. \\

to:

Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.

Changed line 14 from:

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

to:

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

Changed line 38 from:

2) Compile the C source file:

to:

2) Compile the C source file:

Changed line 42 from:

3) Move the executable into the web hierarchy:

to:

3) Move the executable into the web hierarchy:

Changed line 46 from:

4) You must identify the CGI pattern to thttpd. This can be done two ways:

to:

4) Identify the CGI pattern to thttpd. This can be done two ways:

Changed line 56 from:

5) You access the CGI file through a browser using:

to:

5) Access the CGI file through a browser using:

November 08, 2004, at 06:27 AM by michaelebrownmindspringcom --
Changed lines 1-60 from:
to:

Goal:

Compile a C program to make a CGI executable for thttpd.

Prerequisites:

Installation of HomePage Unslung?.
Successful completion of NativeNSLU2Toolchain, which provides a development environment on your NSLU2.
Steps:

Here's the Hello program turned into a CGI executable for thttpd.

1) Create the C source file, webhello.c, using the editor of your choice. Here's the code:

    #include <stdio.h>

    main()
    {
	/* Necessary for page header */
	printf("Content-type: text/html\n");
	printf("\n");  /* This blank line is critical! */

	/* Here is the simplest starting HTML */
	printf("<html>\n");
	printf("<body>\n");

	/* Your HTML goes here */
	printf("Hello, World!\n");

	/* and the simplest ending HTML */
	printf("</body>\n");
	printf("</html>\n");

	return 0;
    } 

2) Compile the C source file:

    gcc webhello.c -o webhello.cgi

3) Move the executable into the web hierarchy:

    mv webhello.cgi /share/udd/www/

4) You must identify the CGI pattern to thttpd. This can be done two ways:

    On the command line:

        /usr/bin/thttpd -c '**.cgi'

    Or, in the config file as:

        cgipat=**.cgi

5) You access the CGI file through a browser using:

    http://www.nslu2.com/webhello.cgi

That's it!

view · edit · print · history · Last edited by mwester.
Based on work by RXPKW, MK, UXAOX, fixer, ZluZm, tino, tman, and michaelebrownmindspringcom.
Originally by michaelebrownmindspringcom.
Page last modified on May 09, 2008, at 01:25 AM