When the base URL is retrieved, without a query string attached, the program returns data which the client interprets as a document with a searchable index. When the modified URL is retrieved, on the other hand, the program performs the appropriate search and returns data which the client interprets as a document containing the search results. If the URL is not that of a program, but of a static document, then instead of running a program, the server will simply return the document. Query string given on the command line as an argument to the program in a URL-decoded form. The former method is the more commonly used, as it obviates the trouble of decoding the query string.
Output When called by a server, all data sent by the program to stdout goes to the client.
Before sending the search results to the client, the program must first send a header followed by a blank line so that the client knows what is coming. It checks to make sure the finger program exists on the machine and is executable. If not an error is returned and the program terminates. It checks to see if a query string has been passed to the program. In the absence of a query, the program returns to the client an HTML document explaining the finger gateway.