Iran appeared today to be moving closer to putting U.S. Embassy hostages on trial following televised charges of American "espionage" here.

The militant student captors denied that the broadcast, in which at least one hostage described what he said were U.S. intelligence activities in Iran, signaled any campaign by them to push for hostage trials.

But Western diplomats here said U.S. political and economic sanctions against Iran now make it more likely that the captives eventually will be tried.

Meanwhile, Iran's official radio reported that Iran has dispatched a naval task force to patrol the northern waters of the Persian Gulf to discourage sea attacks by neighboring Iraq. The radio did not give the number or types of vessels in the task force.

Statements by Iranian military leaders on the growing tension between Iran and Iraq were contradictory, however.

The commander of Iran's ground forces, local Revolutionary Guard commanders and Iranian news media reported clashes along the Iranian-Iraqi border ranging from air strikes to knifings, both yesterday and today. The head of the armed forces joint staff said today, however, that the border had been "completely calm" yesterday afternoon.

In Tehran, 40 Iranian diplomats, expelled from the United States after President Carter severed relations with Iran earlier this week, were given a triumphant welcome at Mehrabad Airport this morning by a crowd of several thousand chanting, "Death to America."

One Tehran newspaper marked the arrival with the headline: "Iranian Diplomats Back From Land of Great Satan."

At the occupied U.S. Embassy where captive American diplomats were spending their 159th day in captivity, the militant Moslems said last night's television presentation about the purported U.S. espionage was "to show the crimes of the U.S. to the Iranian people and the world."

For the second time in three days, the militants and the state-run television system haggled with U.S. networks over possible sale of the hostage film. Earlier this week the three U.S. networks paid $12,000 each for films of Easter services for the hostages but it was unclear whether they would buy the film showing alleged U.S. intelligence facilities.

There was confusion today over how many hostages actually appeared in the broadcast.

The Iranian announcer at the beginning of the program said "two spies" would "reveal some shocking things," and most Western observers who saw the entire program said the explanation of alleged American espionage appeared to come from two different hostages.

But the militants insisted today that only one hostage -- Army Staff Sgt. Joseph Subic Jr. -- was shown, but that he appeared in different clothes in different settings in different times. The militants said the film was shot about a month ago.

Asked why the broadcast was delayed for nearly a month, a spokesman for the militants said they "wanted to be a little quiet during the election time." He was referring to last month's first round voting for a new Iranian parliament, for which a final runoff has yet to be scheduled.

The militants denied that the film had anything to do with promoting hostage trials.

"We are not thinking about trials of hostages because it's not our job," a spokesman said. "That's for the parliament to decide."

The spokesman added, however: "If they [the hostages] are spies and did something making these problems for Iran, I think it is Iran's right to put them on trial."

Adding to recent public calls for hostages trials from Iranian political groups, including the powerful Islamic Republican party, was a high official of the pro-Moscow Tudeh (Communist) Party. He said, "The hostages should be tried or at least called as witnesses."

A European diplomat said, "Any further Western steps will automatically, inevitably mean this sort of thing will happen. It's the only thing [the Iranians] can do."

Another diplomat, who also had seen the hostage film said, "I should think there's a good chance" that trials would eventually be staged for at least some of the captives.

As distastefull as such trials would be to the United States, some diplomats said they may prove to be a way for the government of President Abol Hassan Bani-Sadr to assume control of the hostages and extract itself from the confrontation with the United States.

The diplomats speculated, as they have in the past, that after staging show trials to air their grievances and further humiliate the United States, Iran might expel the Americans.

However, an understanding on such an outcome would be difficult, if not impossible, to negotiate under the circumstances, the diplomats cautioned, and there probably would be no guarantee that Iran would not punish some of the captives.

One envoy said of trials, "They may give us a chance to see those hostages we are not supposed to see and who haven't been visited."

In western Iran, meanwhile, conflicting reports of fighting with Iraqi forces were accompanied by belligerent statements from Iranian military leaders.

The commander of the Revolutionary Guard at the border town of Qasre-Shirin was quoted as sayinb that his troops inflicted severe punishment on Iraqis at four nearby villages.

"If they [Iranian leaders] give us the order, we will advance to Baghdad," the local commander said.

Iranian newspapers reported that Iraqi forces attacked Revolutionary Guards and were supported by helicopters, tanks and artillery before being forced to retreat when Iran sent a U.S.-made F4 Phantom fighter-bomber and two helicopters into the battle last night.

Today, the official Pars news agency reported that three Revolutionary Guards were killed and 25 wounded in three clashes near the western Iranian city of Kermanshah.

Iran's ground forces commander said that "in the central area there is the probability of an offensive by the Iraqi Army on a wide scale." He added that the outcome of the fighting would "depend on the probable air battle."

On their arrival here today shortly before 1 a.m., the expelled Iranian diplomats, led by former charge d'affaires Ali Agah, were greeted by Foreign Minister Sadegh Ghotbzadeh, Greek Catholic Archbishop Hilarion Capucci, Foreign Ministry officials and a throng of Iranian chanting, "Death to America."

Agah said on his arrival, "I am sure we shall be victorious, and our victory in making the U.S. kneel has been unprecedented. The U.S. has not been humiliated and destabilized so much even in its defeat by Vietnam."