A trainee stonemason, who was on a night out with friends, fell asleep on a railway track causing a train driver to jam on the emergency brakes in a bid to avoid him.
Eric Rogan (22) had taken a wrong bus and thought the quickest way to get home was to walk along the railway tracks between Rush and Lusk railway station in North County Dublin, Balbriggan District Court heard.
Rogan was spotted lying asleep on the railway tracks at 12.20am by the vigilant train driver, who managed to stop the train by applying the emergency breaks.
Rogan, of St Catherine's Avenue in Rush, pleaded guilty to trespass on Iarnroid Eireann's railway line between the two North County Dublin towns on October 9 last year.
Garda Sergeant Tony Tighe gave evidence that gardai received a call from the train driver that a male was asleep on the railway tracks.
"The driver of the train travelling northbound was vigilant and spotted the defendant in time," said Sgt Tighe.
He added that the situation could have been "tragic" were it not for the quick actions of the driver.
Sgt Tight said that Rogan, who was highly intoxicated at the time, has no previous convictions.
Judge Patricia McNamara remarked that Rogan "in a sense, is lucky to be in court today".
Defence solicitor Fiona D'Arcy said the young man had been "on a session with his friends".
"He took the wrong bus home and thought the quickest way to get home was to walk along the railway lines," explained Ms D'Arcy.
She said the defendant understands he gave the train driver and the passengers an awful fright.
Rogan is currently completing a FAS stonemason's course and is extremely concerned over having a conviction, the court heard.
"This was a very dangerous thing to do and could have caused a major incident, never mind you being killed," Judge McNamara told Rogan.
She ordered him to make a charitable donation of €150 to The Samaritans and if he makes the payment by the end of March, she said she will apply the Probation Act.