devxlogo

Getting CGI Output

Question:
Using C or C++ for CGI programs, is there a way to make a CGI program that calls another CGI program, and then takes the output of that called CGI program, and displays (to the client only) some selected text from the output of the called CGI program? For example, A CGI program that can use the Yahoo CGI program to display to the user only the first search result of a Yahoo search.

Answer:
A CGI program is a process, and as such, it has a distinct address space. Therefore, you can’t pass values directly from one CGI program to another unless you use some sort of interprocess communication (IPC), such as, sockets, shared memory or pipes. However, you can avoid the hassles of IPC by writing the results of the first CGI program into a file and then have its caller read the data from that file, filter it, and display it to the user.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.