WALTHAM, Mass. — The actor who played Luke Duke on the 1980s television show “The Dukes of Hazzard” pleaded not guilty on Thursday to grabbing the buttocks of a female member of the cast of a musical he was supposed to appear in.

Tom Wopat was released on $1,000 bail and was told to stay away from the woman after denying indecent assault and battery and drug possession charges. He refused to comment outside court before driving away.

Wopat, who’s from New York, inappropriately touched the woman on July 23, prosecutors alleged.

“During a rehearsal the defendant allegedly walked behind a female cast member, grabbing her buttocks,” they said in an emailed statement.

Wopat, 65, was arrested on Wednesday night on a warrant on the indecent assault charge as he was leaving Waltham High School, where he was rehearsing for a performance of “42nd Street.” Police said that during a search of him and his vehicle they found “two bags of white powder believed to be cocaine.”

The actor denied touching anyone inappropriately, according to court documents. He said he flirts but did “nothing that could be considered inappropriate.”

Wopat was supposed to play Julian Marsh in “42nd Street” at the Waltham-based Reagle Music Theatre of Greater Boston starting Thursday. But the theater announced Thursday that a different actor would play the role.