When an action for the recovery of real property is pending, upon motion of either party, and for cause shown, the court may make an order describing the property, and allowing such party to enter thereon and make survey thereof for the purpose of the action. A copy of the order shall be served on the owner or occupant, and thereupon such party may enter upon the property, with necessary surveyors and assistants, and make such survey; but, if any unnecessary injury is done to the property, the party is liable therefor.