They stand at almost every street corner in Japan, peddling goods that range from skin magazines to coffee brewed on the spot. Some wink at passers-by with electric red eyes. Others offer games of chance and cajole customers in disembodied voices.

Vending machines are the tireless servants of Japan's high-speed society that eats and shops on the run. Increasingly, they come with electronic innards that make the sale as memorable as whatever is purchased.

The vending machine first appeared in ancient Egypt, history books say, doling out holy water in exchange for a coin. It has reached full blossom in modern Japan, evidence again that the Japanese excel at wringing the full commercial potential from other people's inventions.

Japan has more than 5 million vending machines. What astonishes foreigners is the variety of the wares. American machines offer mainly beverages, snacks and cigarettes. In Japan, the machines sell just about anything small enough to fit inside.

Machines at one Tokyo shrine dispense fortunes for 50 yen, or about 25 cents. They sell bait at a popular fishing spot. Pulp magazines do well in machines -- there is no clerk to stare at you -- and a Tokyo Christian center, not to be left behind, is selling Bibles and other religious books by machine. Socks, razors, records and batteries are sold by them, too.

"When I'm in a rush," said Tadahiko Matsubara, chief director of a Yokohama company that services oceangoing ships, "I prefer the machines." Japan's 120 million people are rarely at rest. Vending machines do well.

People in some cultures fear machines. But the Japanese, especially young ones, get an extra boost from buying if they punch buttons or manipulate glowing numbers along the way.

"Japan goes to the extreme with gadgetry," said Shori Sawatari, director general of the Japan Vending Machine Manufacturers Association.

Sales of machines took off in the early 1960s, as the postwar recovery's returns began coming in, and, equally importantly, the spread of western consumer culture weaned the Japanese from a traditional reluctance to drink straight from the bottle.

Japan's low rates of crime made vandalism and break-ins negligible. The machines could be set up outside, along streets, and left on for 24 hours. Operators quickly found, however, that the country's lack of sidewalks made automobiles a menace. Today, most machines carry collision insurance.

The market here is nearing saturation so producers are hard at work on "improved" models. This year, about 400,000 machines will be turned out. Salesmen will scour truck stops and small businesses with the message that the customers will disappear if the machines get out of date.

Each year, the product line a single machine can offer gets bigger. It takes five steps to coax a cup of coffee from a "Super Brewer" found at a rest stop on the highway to Tokyo's Haneda Airport, for instance. But the machine can serve up 126 different types by varying cream, sugar, strength and type of bean used, all at the customer's command.

Some machines produce a light show when the money goes in. Some run a lottery with each transaction, offering a free drink to each winner (there are few). Others have electronic voices that thank the customer and ask that the cup be disposed of properly.

More and more machines accept banknotes. Owners found that was a mixed blessing a year ago when new-design banknotes were introduced, forcing them to spend hundreds of millions of dollars modifying the machines.

Some also take gift certificates that are increasingly popular holiday items. A hotel in Nagoya, meanwhile, has gone one step further, wiring its machines so guests can charge purchases to their bill by inserting their room key.

Since 1979, many of the new machines have contained microcomputers. Using advanced research, manufacturers are now working on machines that can understand the human voice, allowing customers to deposit money and do the rest by mouth.

Vending machines have left a host of social issues in their wake. Foremost is alcohol. In the United States, it is illegal to sell alchohol by machine, but Japan has no such controls. About 170,000 machines, many of them untended, offer products that include minikegs of draft beer, sake and whiskey by the fifth. Their sales in 1984 came to about $650 million.

Government officials and parents periodically protest that juvenile drinking is encouraged by the machines, while the industry argues that no such link has been proven. As a compromise, operators are asked to turn off the machines between 11 p.m. and 5 a.m., the time when errant juveniles are said to be on the prowl. That also is said to curtail drunken driving.

Consumer groups also protest sale of sex magazines and cigarettes. In November, the All-Japan Anti-Smoking Liaison Council demanded that the government rein in the machines. The council estimates that 600,000 schoolchildren buy cigarettes each year from them.

Old people sometimes gripe that the machines are wiping out a tradition similar to gossip at the general store in old-time America. Kotoko Takahashi recalled that she used to buy cigarettes at a kiosk in her work building. Then, a few years ago, the human disappeared and was replaced by a machine.

"I don't like it," she said. "Person-to-person contact is much nicer."