It was Town's first win of the season - but it was not easy - as they came up against a stubborn Carlisle team.
They fell behind early in the game through Ryan Edmondson's goal on 13 minutes.
But Luke Leahy scored on the stroke of half time with a brilliant free-kick meaning they went into the interval on level terms.
Cotterill's team thought they had the winner 15 minutes from time after Daniel Udoh's shot from close range.
But Carlisle refused to be beaten, and they made it 2-2 via a Kristian Dennis goal from close range.
Chey Dunkley's late winner was enough to see Salop go through to the next round.
And the boss thought his side deserved to win the game.
He said: "Overall I think we have done enough to win the game.
"We were the better team, and then they scored against the run of play, which has given them a leg up in the game.
"Something will happen tonight, there will be a team out there that gets knocked out and no one ever will have seen that coming.
"On these games, you just have to make sure you are not the team.
"So I really really could not be any more pleased for the lads.
"I have seen the work they have put in and sometimes when it doesn't come off it is really difficult to try and get a result.
"I am really pleased for them tonight, I am."