Engineer named Scotty: reference to what pre-Star Trek book or movie?

I read that James Doohan was asked to try various accents for the engineer character and he suggested that the character be a Scot because of Scotland’s tendency to turn out great engineers.