Shola came off the bench to open the scoring with a deflected 84th-minute shot, and Sammy made sure in the fourth minute of stoppage time to book the Magpies' place in the third round of the Capital One Cup, something which had looked far from certain for much of the previous 80 minutes or so.
It was a first win of the season for manager Alan Pardew, who fielded a much-changed side, but was far from convincing.
Jim Bentley's men enjoyed the better of the first half and created four gilt-edged opportunities to take the lead, and only the vigilance of Dan Gosling and keeper Rob Elliot prevented them from doing so.
Gosling, handed the task of guarding the near-post area for defensive corners, hacked Mark Hughes' 10th-minute header off the line, and somehow managed to smuggle away Padraig Amond's attempt 11 minutes later.
Amond proved something of a menace and Elliot was called upon twice in quick succession to deny him as the winger managed to find space all too easily.
Newcastle had chances of their own, none of them better than the one with which half-time substitute Shola Ameobi was presented within four minutes of his arrival.
Gosling's through-ball handed him a one-on-one with keeper Barry Roche, but his finish was wild.
Morecambe combined a fluidity in their play with a physical presence which rattled the visitors at times, with France international Mathieu Debuchy being given a rough ride by experienced striker Kevin Ellison.
By contrast, the Magpies repeatedly went long in a bid to get in behind their hosts, too often with little success until their late salvo.