How To Write A CGI For The Apache Web Server in C
How To Write A CGI For The Apache Web Server in C
How To Write A CGI For The Apache Web Server in C
3. Step: Transfer the executable cgi-demo from the coLinux directory to the Windows directory /windows/transfer. Then run a TFTP server within the Windows environment.
4. Step: Run a Telnet or SSH session. Then execute the following commands: cd /rwnv/opt/lampp/cgi-bin tftp binary connect 192.168.0.2 get cgi-demo quit chmod +x cgi-demo
Please note: This sample assumes that your development PC with Windows and coLinux is using the IP address 192.168.0.2. Change this address if necessary. 5. Step: Access the executable cgi-demo with your Web browser. The URL for this CGI on the Com/PC is: http://192.168.0.126/cgi-bin/cgi-demo
This URL assumes that your Com/PC is using the IP address 192.168.0.126. Change this address if necessary.
// SERVER_SOFTWARE pEnvPtr= getenv ("SERVER_SOFTWARE"); printf ("SERVER_SOFTWARE= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // SERVER_NAME pEnvPtr= getenv ("SERVER_NAME"); printf ("SERVER_NAME= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // SERVER_PROTOCOL pEnvPtr= getenv ("SERVER_PROTOCOL"); printf ("SERVER_PROTOCOL= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n");
// SERVER_PORT pEnvPtr= getenv ("SERVER_PORT"); printf ("SERVER_PORT= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // REQUEST_URI pEnvPtr= getenv ("REQUEST_URI"); printf ("REQUEST_URI= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // REQUEST_METHOD pEnvPtr= getenv ("REQUEST_METHOD"); printf ("REQUEST_METHOD= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // GATEWAY_INTERFACE pEnvPtr= getenv ("GATEWAY_INTERFACE"); printf ("GATEWAY_INTERFACE= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // HTTP_CONNECTION pEnvPtr= getenv ("HTTP_CONNECTION"); printf ("HTTP_CONNECTION= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // PATH_INFO pEnvPtr= getenv ("PATH_INFO"); printf ("PATH_INFO= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // PATH_TRANSLATED
SSV EMBEDDED SYSTEMS 2007, mHT-CPC1L-010.doc, Rev. 1.00.
pEnvPtr= getenv ("PATH_TRANSLATED"); printf ("PATH_TRANSLATED= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // REMOTE_HOST pEnvPtr= getenv ("REMOTE_HOST"); printf ("REMOTE_HOST= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // REMOTE_ADDR pEnvPtr= getenv ("REMOTE_ADDR"); printf ("REMOTE_ADDR= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // REMOTE_PORT pEnvPtr= getenv ("REMOTE_PORT"); printf ("REMOTE_PORT= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // REMOTE_IDENT pEnvPtr= getenv ("REMOTE_IDENT"); printf ("REMOTE_IDENT= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // SCRIPT_FILENAME pEnvPtr= getenv ("SCRIPT_FILENAME"); printf ("SCRIPT_FILENAME= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // SCRIPT_NAME
pEnvPtr= getenv ("SCRIPT_NAME"); printf ("SCRIPT_NAME= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // QUERY_STRING pEnvPtr= getenv ("QUERY_STRING"); printf ("QUERY_STRING= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // CONTENT_TYPE pEnvPtr= getenv ("CONTENT_TYPE"); printf ("CONTENT_TYPE= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); // CONTENT_LENGTH pEnvPtr= getenv ("CONTENT_LENGTH"); printf ("CONTENT_LENGTH= "); if (!pEnvPtr) printf ("<NULL-POINTER>\n"); else printf ("%s\n", pEnvPtr); printf ("<br>\n"); printf ("</BODY>\n"); printf ("</HTML>\n"); return (EXIT_SUCCESS);
That is all.