If judgment is recovered by the plaintiff, and it shall appear that the property has been attached in the action and has not been sold as perishable property or discharged from the attachment as provided by law, the court shall order and adjudge the property to be sold to satisfy the plaintiff's demands, and if execution issues thereon, the marshal shall apply the property attached by him, or the proceeds thereof, upon the execution, and if there is any such property or proceeds remaining after satisfying such execution, he shall, upon demand, deliver the same to the defendant.