ST. LOUIS (AP) — The month of August has been great for rookie pitcher Jack Flaherty and the St. Louis Cardinals.

Flaherty allowed just one run in seventh innings and Jose Martinez and Tyler O'Neill homered and the St. Louis Cardinals beat the Pittsburgh Pirates 5-2 Tuesday night in Mike Shildt's first game since being promoted to full-time manager.

Flaherty (8-6) retired his first 12 batters and gave up one run and four hits with no walks. He is 4-0 with a 1.13 ERA in five August starts. Flaherty has allowed only 14 hits and three runs in 32 innings, walking nine and striking out 38 batters in those starts.

The recipe for his success is simple, Flaherty said.

"Get ahead and stay ahead. Try not to get into deep counts and try to stay from a 3-2 count," Flaherty said. "Try to make things happen quick. Move the ball in and out. Trust in my stuff."

A meeting two weeks ago with Cardinals legend Bob Gibson inspired Flaherty.

"I got the chance to talk to him," Flaherty said. "I asked him what his mentality was every time he went out. I haven't talked to him since then but it's more on me to reach out to him and than the other way around."

Flaherty improved to 3-1 against the Pirates.

"He's gotten better the more we've faced him I think as this season has shown," Pittsburgh manager Clint Hurdle said. "His stuff has gotten better, the consistency of it, the execution of pitches."

The Cardinals have won six of seven and are 20-5 in August. Earlier in the day, St. Louis took off the interim tag on Shildt, who was put in charge after Mike Matheny was fired last month a day before the All-Star break.

St. Louis is 27-12 under Shildt. He was rewarded with a contract through 2020 after guiding the Cards back into playoff contention.

"He's been doing his thing and he hasn't tried to do too much," Flaherty said about Shildt. "He hasn't tried to change anything. It's just been him. I think the biggest thing is for everybody to be themselves and he's done the same thing. I'm just happy for him."

The Pirates have lost eight of 10.

Bud Norris pitched the ninth for his 28th save in 32 opportunities.

Martinez hit a two-run homer in the first off Ivan Nova (7-9). Martinez connected for his 16th homer after Matt Carpenter reached base on an infield single.

"I was trying to drive a ball middle in and he threw it there and I hit it out," Martinez said.

O'Neill hit a 436-foot homer into the left field bleachers in the fourth inning for a 4-0 lead. Martinez singled ahead of O'Neil's drive.

"The command, it was not as sharp as it was last time," Nova said. "I gave up two two-run homers. The first home run, I thought that was a really good pitch that the guy just jumped on. The other one was down the middle of the plate. It's frustrating."

Josh Bell scored both runs for the Pirates. He doubled in the fifth and Colin Moran hit an RBI single.

Bell drew a leadoff walk from reliever Jordan Hicks in the eighth, took third on a bloop single by Moran and scored on a double play.

Paul DeJong was hit by a pitch to start the St. Louis eighth and an apparent two-run homer by Jedd Gyorko was overturned in a crew chief review. Gyorko was given a double and he was pulled because of discomfort in his left groin. Greg Garcia's single made it 5-2.

Gyorko said he hurt himself leaving the batter's box. He said it's "tightness" and he will be looked at Wednesday.

"I thought it was a home run," Gyorko said about his hit. "I ran around the bases. I haven't looked at it yet."

TRAINER'S ROOM

Pirates: Josh Harrison didn't start for the second consecutive game after tweaking his left hamstring Saturday running from first to third. He walked as a pinch-hitter in the eighth and stayed in the game at second base.

Cardinals: 2B Kolten Wong was put on the 10-day disabled list with a left hamstring strain, retroactive to Aug. 26. Wong, who injured his hamstring while running out a ground ball in Saturday's game in Colorado, was batting .244 with eight home runs and 32 RBI in 110 games.

WACHA START

Starter Michael Wacha (left oblique strain) left in the third inning with a trainer at Double-A Springfield after allowing five earned runs on six hits in 2 1-3 innings Tuesday against Arkansas. He threw 52 pitches and exited because of fatigue, the Cardinals said. Wacha, who will be evaluated Wednesday, went on the disabled list June 21 and has missed 60 games.

ROSTER MOVE

With Wong going on the disabled list, the Cardinals recalled INF Patrick Wisdom from Triple-A Memphis. Wisdom, 27, is batting .288 with 15 home runs and 61 RBI in 107 games for Memphis. Wisdom was purchased from Memphis on Aug. 11 and played in nine games for the Cardinals, batting .333 (4 for 12) with a home run and three RBIs. He had played in 747 career minor league game before his major league debut.

UP NEXT

Pirates: RHP Trevor Williams (10-9, 3.44) has allowed just four runs in his last seven starts covering 42 innings. He is 2-4 with a 6.93 ERA in 10 career appearances, including seven starts against St. Louis. He is 1-2 in four starts this year.

Cardinals: RHP Miles Mikolas (13-9, 2.94) allowed a season-high 12 hits and five runs in 4 2-3 innings in last Friday's start at Colorado. He lost to the Pirates on June 1 at Busch Stadium.