Thousands of trucks rumble into South America's largest port each day, hauling everything from auto parts to coffee bound for Europe, Asia and the United States. At least that's what the paperwork says, although it turned out to be wrong in one telling security breach involving about 40 containers of Brazilian coffee beans last year.

Without opening the containers, it would take an X-ray or radiation detectors to reveal what's inside. Those are two of several screening measures scheduled to start July 1 to prevent terrorists from shipping explosives, guns and other deadly material, although only one in 10 ports around the world has met the requirements so far.

Santos port officials say their security plan will be approved before July 1. But it will take months to implement, including constructing miles of higher fences, installing an electronic identification system for 20,000 people who pass through the port's 60 entrances daily and putting up a closed circuit monitoring system with nearly 500 cameras.

Now, small ferries motor near enormous freighters taking on stacks of containers as security guards give paperwork cursory checks. Getting inside the port and close to docked ships isn't hard, a factor that experts say could make it an inviting place for terrorists planning to hijack ships or use containers to smuggle weapons of mass destruction to overseas targets.

Failure to comply with the July 1 date imposed by the International Maritime Organization, a U.N. agency, could cause trade problems if major shipping countries turn away or perform lengthy inspections on ships calling at ports that don't meet the new security standards.

Ships heading to the United States from ports that don't comply with the code, for example, could be searched by the U.S. Coast Guard and, in the most extreme cases, be ordered back to sea.

By mid-June, only 654 of the 6,114 ports subject to the international security code -- established under pressure from the United States in the wake of the Sept. 11 attacks -- were in compliance.

Chris Austen, chief executive of the British firm Maritime & Underwater Security Consultants, is working with 300 ports, and many are still ordering equipment such as closed-circuit TVs and training.

"Many ports only started working on it in May," he said.

Complicating efforts to boost security, ports tend to be dangerous places full of questionable characters and criminal elements.

"You go there at night, and you will be beaten up by gangs," Austen said. "Ports are full of scoundrels."

More than 40 containers, each filled with 23 tons of Brazilian coffee, were cleared by customs officials at an inland facility in late 2002 and early 2003 and taken by trucks to Santos for shipment to New Orleans, Rotterdam and other ports. When they were opened, there was only dirt, cement or sand inside matching the weight of the purported coffee.

Police suspect truckers were involved in a scheme to steal the cargo and identified ringleaders but failed to get convictions.

Inspectors have since stepped up spot checks of cargo leaving Santos but are opening only about 3 percent of the containers, said Jose Carlos Ramalho, chief of the anti-contraband unit of the Santos customs office.

Security experts say it is impossible for authorities in any country to check all of the millions of containers that travel around the globe -- even with expensive scanners that can see inside containers and radiation detectors to guard against concealment of a radioactive "dirty bomb."

Elsewhere around the world, security upgrades are hit or miss:

* In Port Haina, the Dominican Republic's largest port, cranes and construction workers are building security buildings while technicians measure for the installation of container-sized X-ray machines.

Software experts troubleshoot a computer program that tracks goods coming in and out while security guards remind workers to show their electronic badges.

* Nigeria's main port in Lagos, the largest in West Africa, recently acquired mobile container scanners. A high wall surrounds the port, but a reporter wasn't asked for identification before entering.

Shipments of narcotics and guns in and out of the port are common, arranged by criminals who bribe port officials, said Emeka Okoroanyanwu, editor of the Lagos-based Maritime Quarterly trade publication.

And highly organized thieves known as "wharf rats" have such access to the port that more than 80 percent of the used cars brought into Nigeria on open ships are vandalized so parts can be stolen, said Chika Ezenwe, a licensed cargo clearing agent. "The only ones that are safe are those that come inside containers," he said.

The head of the Nigerian Ports Authority, Adebayo Sarumi, said in a speech in March that Nigeria and neighboring countries had not done enough to meet the security code.

* In the Indonesian port of Batam, a 45-minute ferry ride from Singapore, almost anyone can walk in with a wave to unarmed guards. Motorcycle taxis roar throughout the port, and street vendors sell food from tiny stalls next to ships unloading cargo. The closest security guards are 400 yards away at the port's main entrance.

Batam did put in a higher fence to meet the security code, and guards are receiving extra training, but port director Sudirman Purwo said it's unlikely the port will meet the July 1 deadline.

Though Brazil is scrambling to make sure its 183 ports have security plans in place, the government didn't release $32 million in funding to boost security until May.

At Santos, new moves to monitor who gets inside the port will be a significant improvement, said Mariliza Fontes Pereira, who heads the port's compliance task force. Hundreds of additional security guards will scrutinize trucks as they enter, and a radar system will eventually be installed to make sure small boats don't get too close to big ships.

"You'll never be 100 percent safe, but if there are any suspicions about a trucker or his cargo, he won't be able to go to the docks," she said. "The police will be called and his cargo will be checked."

Even before the security rules were established, Santos had tighter security than many other ports in developing countries. Vendors hawking food and international phone cards set up shop just outside the port's gates but aren't allowed inside. Security guards with digital cameras stop trucks with containers of imports before they leave the port so the truckers can be photographed in front of their rigs' license plates.

Austen, the security expert, said the new security rules shift the emphasis from preventing theft to preventing terrorism.

"Now people are worried about the cargo leaving the port being a threat and the ships themselves being a threat," he said.

Efthimios Mitropoulos, secretary general of the International Maritime Organization, warned that shipping could be disrupted if ports don't quickly come into compliance. But security experts doubt politicians will want to be blamed for harming the delicate world economy, especially President Bush, who is in the midst of a reelection campaign.

"No one in the shipping business believes that international trade will suddenly shut down," said Jim Hunter, a partner with the Merlin Risks security firm advising two Brazilian ports. "People are hoping as long as you are making a good faith effort to comply, you won't pay too high of a price for lack of performance."

The Bush administration plans to move cautiously on enforcement.

"If we don't get it right, we end up slowing things down or shutting things down, and that's not what we want," said U.S. Coast Guard spokeswoman Jolie Shifflet.

Container ships are seen at the port of Santos in Brazil, where hundreds of guards will scrutinize trucks.