First half-tries from Brett McNamee and Ross McCarron, and a conversion and two penalties from outhalf Barry Keeshan had Ireland 18-10 in front at the interval.
Ireland went further ahead when McCarron scored his second try, which Keeshan converted, but the Scots struck back in injury-time with a try to cut Ireland's lead to just three points (25-22). However, Keeshan then had the final say with a penalty five minutes into injury-time.
Ireland's final game will be against either England or Wales on Sunday at Stade Jean Bouin, home to Stade Francais.
Ireland. Ross McCarron - UCD; Kieran Geraghty - Colston College, Greg Stafford - Lansdowne, Breiffne O'Donnell - UL Bohemians, Marc Hewitt -Skerries; Barry Keeshan - UCC, Steven Auld - Belfast Harlequins; Frank Leonard - UL Bohemians, Gary Maxwell - Dungannon