Gary Johnstone (23) posted the message where the general public could see it, urging people who saw PC Gary MacKie to smash him, or “even slash, stab or batter him”.
“It was an awful thing to post,” Sheriff Scott Pattison told Johnstone.
“It is as bad as I have heard.
“This was a vile and threatening message inciting specific violence against a serving police officer.”
Johnstone, of 3 Barrow Park, Blackwood, admitted posting a message of a grossly offensive or menacing character on Facebook on February 25 this year.
He had been due to stand trial at Lanark Sheriff Court on Wednesday, but changed his plea to guilty.
The court heard that he had posted the message on a Lanarkshire Buy and Sell page on Facebook.
In the message, read out in full in court, he said he was going back to prison, for the second time for an offence he had not committed, then he launched into the remarks about the police officer.
He stated in the message: “This is inciting violence against a Police Scotland officer and I don’t give a f..k.
“If they won’t sack him, then the people will eradicate him, more than he deserves, the little f...ing rat.”
And it went on: “Hope you are proud, Gary MacKie. You have f..ked up my life, you little scummy f..ker. I am coming for you. That is a f..king promise.
“You are f..cking dead mate.”
The court heard that the post came to the attention of the police.
A solicitor said that Johnstone had been very drunk when he posted the message.
“He posted this message in a drunken stupor about 4am, and it had been taken down by lunchtime, when Johnstone became aware of what he had posted” said the solicitor.
“He is extremely remorseful,” added his solicitor, who initially asked the sheriff to deal with the matter by imposing a fine.
Johnstone’s partner had his own consultancy firm and Johnstone, with assistance from his partner, had set up his own IT firm.
But Sheriff Pattison made it clear this was not an option.
“It is an awful thing to post,” he said.
Being drunk was not an excuse, and Johnston had a record of previous convictions.
The court had to impose punishment and deterrence, and he sent Johnstone to prison for the six months.