Shaw was seen dropping a bag of tablets out the window of his van
A former soldier has been jailed for six months after being found with nearly 150 ecstasy tablets.
Andrew Shaw, 21, was in the process of formally leaving the Black Watch when he was caught during a routine check by traffic police in Perth in May.
Officers spotted him dropping a bag containing five tablets out of the window. A further 139 pills were found when his transit van was searched.
He admitted possessing and supplying the drug at Perth Sheriff Court.
Shaw, from the town, admitted he had driven to Dundee to bulk-buy the tablets.
He said he was going to meet friends in a nightclub and pass on the ecstasy, as well as keeping some for himself.
Shaw, who served in Afghanistan and Northern Ireland, also admitted breaching a bail condition to stay indoors at night.
He told the court that he left his home on 16 June to travel to Fort George barracks to formalise his exit from the military.
Shaw had been working as a driver for Perth and Kinross Council and had previously played football for Scotland at under-16 level.
Solicitor John McLaughlin, defending, said: "He feels he has let everyone down.
"He has previously been of good character and behaviour and he worked hard in the army and left of his own volition. He had a good service record.
"This is a man who deserves a chance. He is not a stranger to hard work. He is someone who could benefit himself and society from a community disposal."
Sheriff Lindsay Foulis told Shaw it was "disappointing" that someone like him had ended up in court on such a serious charge.
He said: "The amount of tablets found, where they were found, the place you intended to supply them - a nightclub - all make it more serious.
"You knew where to get them and you were quite willingly acting as a courier. I consider a custodial sentence is appropriate."