cgi|perl|server|web| program Source: ZERODJ Release
Body:
Write yourself a function to support CGI running ...
Ideas:
When the request for Web server is an execution file,
Then execute the file (using the process), but if you want to pass the data to the CGI how to do it, then the result of CGI run, in their own program how to get it?
Then it can be a pipe, to achieve the sharing of data!
The data submitted by the Web page is available in its own program (socket to get)! Just pass the data to the pipe!
The data that the CGI program needs is read from the pipeline!
When the CGI program is finished, it outputs the results to the pipeline, and its own program reads the contents of the pipe!
Then use the socket to send the results to ie/ns on it!
The following is just a function,
Cgifilename: Name of the CGI program to execute
Value submitted by the Ppostvalue:web page (Submitted by post method)
Ppipevalue: The value of the environment variable (the value submitted by the Get method is placed in the environment variable query_string)
Whether the ISSTDREAD:CGI program needs to read values from the pipeline
Note: The value submitted by the Post method has a variable in the environment variable content_length is the length of the record post submission value!
Each environment variable is separated by the word ' yes ' characters! (query_string=name=66&password=77\0content_length=0\0\0)
When the environment variable end should use \0\0 to end!
Do not use Api:setenvironmentvariable () to set environment variables, but write the value of the post to the CGI program, the environment variables set with this API function will be lost.
HANDLE Hprocess,hwrite,hread,//process handle, pipe write handle, pipe read handle
Security_attributes SA,//security architecture
Startupinfo Mysi,//Child Process window property structure
Process_information Mypi,//child process information
BOOL Btest,//API whether the call succeeds
Fill the security structure so that the handle is inherited
Sa.nlength=sizeof (Security_attributes),
Sa.lpsecuritydescriptor=null,
Sa.binherithandle=true,
Populating process startup information
memset (&mysi,0,sizeof (startupinfo)),
Mysi.cb=sizeof (Startupinfo),
Mysi.dwflags=startf_usestdhandles,
if (!isstdread)
If the CGI (or PHP program) does not take a value from the pipe (using the Get method), use the standard input
Mysi.hstdinput=getstdhandle (Std_input_handle),
Else
is used to read from the pipe
Mysi.hstdinput=hread,
After the MYSI.HSTDOUTPUT=HWRITE,//CGI program runs, it sends the result to the standard output (screen), where it tells the CGI to put
The results are sent out in a pipeline
Mysi.hstderror=hwrite,//cgi program error, change the error message from the pipeline output, (that is, into the pipeline to write information)
To create a child process
Btest=createprocess (NULL,
Cgifilename.c_str (), NULL,
Null,true,//true to allow this process to inherit some of the input and output information set above
Detached_process,
(LPVOID) Ppipevalue,null,&mysi,&mypi),
(LPVOID) Ppipevalue----Transmitted environment variables
if (btest) hprocess=mypi.hprocess,
else return "",
if (isstdread) {
if (btest) {
CloseHandle (Mypi.hthread),
DWORD Dwwritten,
BOOL Breturn,
Char *g=ppostvalue.c_str (),
Write the committed value into the pipeline
Breturn=writefile (Hwrite,g,strlen (g), &dwwritten,null),
if (!breturn) return "",
}
if (!btest) return "",
Wait for the CGI program to finish.
WaitForSingleObject (hprocess,wait_abandoned),
}
Be sure to close the read handle of the pipe
CloseHandle (Hwrite),
Char readbuf[100],
DWORD Bytesread=0,
Ansistring cgiout= "",
The above CGI program after the execution of the result has been written into the pipeline, now just read out on it!
while (ReadFile (Hread,readbuf,100,&bytesread,null)) {
"Readbuf[bytesread]=",
Cgiout=cgiout+ansistring (READBUF),
}
CloseHandle (Hread),
CloseHandle (hprocess),
Return execution results Use the socket to send a user!
Return Cgiout,
}
The CGI program reads the data from the standard input and outputs it to the standard output!
Here with the pipeline, in their own program, the establishment of pipe, let the CGI pipe read from the data or output from the pipe run results!
If you use a file operation in your CGI program!
Such as: Open the file, the text content output!
Note that the file path here uses an absolute path, and if you want to use a relative path, its reference path is the path to your application, not the CGI path.
Zerodj@163.com
Title: Using bind on Linux to establish a DNS server [delete]
Author: Thomas nooning Category: Linux keywords: DNS
Body:
Author: Thomas nooning, TechRepublic
Date: September 19, 2001
Although Linux has not made noticeable progress in the world of desktop computing, it is already a small celebrity as a Web server. Thanks to its excellent reliability, we can safely run all the important service programs that are necessary for today's internet age on Linux. As a result, some of the most common uses of Linux include being used as mail servers, Web servers, and DNS servers.
Here we'll look at how to use bind to establish a DNS server on Red Hat Linux. BIND (Berkeley Internet name domain) is a domain name resolution service package that is implemented on a unix/linux system. We will learn the steps required to build and run a DNS server on Linux, including installation, initial configuration, and system setup.
Download and install <a href=http://www.linuxbyte.net/showsoftd.php?id=224 class=red target=_blank>bind</a>
You can download the BIND source package in www.isc.org/products/BIND/. The latest version is 9.1.3 (when you write this article), and you can download support information and FAQs as well.
In this article we use Red Hat as an example, so you might want to use the RPM version of BIND, which can be found by searching www.rpmfind.net, because using the rpm form of the release package is the easiest way to install bind. After you download the bind rpm, such as bind-9.1.0-10.i386.rpm, you need to execute the RPM-IVH bind-9.1.0-10.i386.rpm command as Superuser. When you install bind in RPM, be careful to check for any missing dependencies that can cause the installation to fail.
If you prefer to install from the source package, after downloading files such as bind-9.1.3.tar.gz, you need to run the tar xvfz bind-9.1.3.tar.gz command to extract it as superuser. For this example, a directory named bind-9.1.3 is generated that contains all the files necessary for the installation. Next, go to the newly created directory and execute the./configure command, run make after the script completes all configuration work, and run make install to complete the installation process. Now you should have the basic configuration of BIND installed on your system, and then adjust it as needed.
Configure Bind
Once you've installed the bind in the system, you can configure it in a variety of ways. One of the two most commonly used is the use of ISP type settings, where the DNS server accepts and resolves requests from anyone (or a predefined set of users), and the other is the web host method that only resolves requests for service domain names. When the use of the server changes, you can also change the type of configuration at any time.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.