
47 Cal.App.2d 68 (1941)
DENNET WITHINGTON et al., Appellants,
v.
E. L. SHAY, as Sheriff, etc., et al., Respondents.
Civ. No. 2919. 
California Court of Appeals. Fourth Dist.  
Sept. 30, 1941.
 Hert & Withington and Robert Mack Light for Appellants.
 Howard A. Andrews for Respondents.
 GRIFFIN, J.
 This cause was submitted upon an agreed statement of facts. So far as those facts are material to the questions here involved, they may be thus summarized: M. J. Nolder Distilleries, Inc., owned certain real property upon which Fox-Woodsum Lumber Company placed a mechanic's lien, and suit was started to foreclose. Ten months and eighteen months thereafter respectively, two purported trust deeds covering the same property were executed by the owner and recorded, one Davis being the trustee and the plaintiffs and appellants being the beneficiaries named therein. Thereupon, Fox-Woodsum Lumber Company made Davis and appellants defendants in its suit for foreclosure of the *71 mechanic's lien and they appeared and contested that action, seeking a determination of the priority of rights.
 Fox-Woodsum Company obtained judgment in its foreclosure suit holding that the trust deeds of appellants were subject and subordinate to the mechanic's lien and ordering that the sheriff sell the property "in the manner prescribed by law" and "pay to plaintiff or its attorney the aforesaid sum so found due to plaintiff." A writ of execution was issued. A copy of the decree containing these recitals and ordering sale of the property was attached. The sheriff was not directed by the writ or by the judgment as to what disposition he was to make of any surplus derived from the sale if the selling price was in excess of the amount required to satisfy the judgment.
 After the sale had been ordered and advertised, but before the day of sale, respondent Schluter became the owner of the judgment. At the execution sale Schluter purchased the property for $6,169.94, which he paid by satisfying the judgment which then amounted to $2,039.91, and gave his personal check for $4,130.03.
 In another action Schluter had previously obtained a judgment against the same judgment debtor, N. J. Nolder Distilleries, Inc., for more than $4,130.03. By virtue of that judgment he levied execution on the excess $4,130.03 cash in the sheriff's hands, and three weeks later it was paid over to him, less costs, by county warrant.
 Appellants never gave any notice to the sheriff or Schluter that appellants claimed any interest or right in any part of the sale price realized at the execution sale until they brought this action.
 At a previous sale under writ of execution previously issued in another action respondent Schluter had purchased the real properties of the Nolder Distilleries, Inc., for a nominal sum, subject to the mechanic's lien and the trust deeds. Schluter had also brought another and separate suit against Nolder Distilleries, Inc., and recovered judgment thereon. That judgment was assigned by Schluter to one Danziger. Under that judgment execution was levied against the right of the Nolder Distilleries, Inc., to redeem their real property from that execution sale and that right of redemption was purchased at the sale thereof by Schluter. *72
 Schluter was vice president and director of the N. J. Nolder Distilleries, Inc., up to the time of his bringing his said action against the said corporation.
 The complaint in the instant action was drawn in three counts: (1) for money wrongfully withheld; (2) a prayer for declaration of rights; and (3) to restrain the sale of property of the buyer. The trial court gave judgment on the pleadings and the stipulated facts in favor of Shay and Schluter from which judgment plaintiffs now prosecute this appeal.
 Appellants argue that the excess funds from the foreclosure sale were in custodia legis when the execution, in the sum of $4,130.03 was levied on by the sheriff, and that the sheriff, in his official capacity as such, could not rightfully and effectively levy upon the money which he himself held as a surplus from the foreclosure proceedings. That even assuming that the levy was effective, Schluter could not hold the funds so acquired as against the present suit of the declared junior lien holders.
 [1] Respondents contend that the trust deeds were not adjudicated to be junior liens and appellants were not adjudged to be junior incumbrancers; that appellants could have notified the sheriff or the judgment creditor that they claimed an interest in or right to any surplus realized at the sale, thus putting respondents on notice; that appellants appeared in the foreclosure action but failed to foreclose, by cross-complaint, their trust deeds and thereby have their validity and effect determined; that they could have had the judgment provide that any surplus from the execution sale, up to the amount due them, be paid over to them if they were entitled to it; that appellants lost their claimed lien on the land when the prior lien was foreclosed and did not acquire a lien on the proceeds of the sale of the lands; that appellants lost their rights, if any they had, by sleeping on them; that under section 691 of the Code of Civil Procedure it was the duty of the sheriff under the foreclosure proceedings to sell the property, pay to the plaintiff or his attorney so much of the proceeds as would satisfy the judgment, and if there were any excess of the proceeds over the judgment and accruing costs, it was his duty to return this excess to the judgment debtor, unless otherwise directed by the judgment or order of the court; that thereby under such directions *73 the surplus, after the sale, was the property of the judgment debtor and was subject to levy, by execution, on Schluter's judgment.
 After issue joined in the foreclosure proceeding, the court should have determined the matters between the parties to the action and provided for a disposition of the surplus proceeds of sale, if any there be, in accordance with the rights of the respective parties. The decree containing no provision for disposition of the surplus, should have been modified to make provision therefor.
 [2] It is a general rule of law that a court may order the surplus remaining after satisfying a plaintiff's debt and costs, to be paid into court to be distributed to the respective parties in interest as their interests may subsequently be made to appear and as the court may subsequently determine. (Code Civ. Proc., sec. 727; Hibernia Savings, etc. Society v. Fella, 54 Cal. 598; Union Water Co. v. Murphy's Flat Fluming Co., 22 Cal. 620; 18 Cal.Jur. 638, sec. 843.)
 [3] We will first determine the effect of the purported levy of execution by Schluter on the surplus funds in the hands of the sheriff. A mechanic's lien is in the nature of a mortgage and is a charge on the land. An action for its foreclosure is a proceeding in equity and resembles a proceeding to foreclose a mortgage or equitable lien. (Curnow v. Happy Valley etc. Co., 68 Cal. 262 [9 P. 149].) [4] The rules relating to civil actions generally apply to proceedings for the foreclosure of mechanics' liens, except insofar as the chapter of the Code of Civil Procedure relating to mechanics' liens has changed such procedure. (Sec. 1198, Code Civ. Proc.)
 [5] The code provisions relating to the foreclosure of mechanics' liens provide no mode of enforcing a judgment other than by a sale of the property and docketing a deficiency judgment against the defendant who may be liable therefor. (Central L. & M. Co. v. Center, 107 Cal. 193 [40 P. 334].) The sale in the instant case was based upon an order of the court. A decree or decretal order for the sale of certain specific property made by a court of equity, differs materially from a common-law judgment. Instead of running against the entire property of the judgment debtor, it specifies the property which the court directs to be sold for *74 the purpose of carrying its judgment into effect; and the officer, in executing this order, acts under the direct mandate of the court without the power or necessity of taking any property from the possession of the defendant. (15 Cal.Jur. 300, sec. 2.) The distinction between an order directing a sale and a writ of execution issued on a money judgment has been judicially recognized in the cases of Hager v. Astorg, 145 Cal. 548 [79 P. 68, 104 Am.St.Rep. 68], and Southern California Lumber Co. v. Ocean Beach Hotel Co., 94 Cal. 217 [29 P. 627, 28 Am.St.Rep. 115]. The source of the officer's power as defined in and circumscribed by the court's order is clearly recognized in the cases of Heyman v. Babcock, 30 Cal. 367 and Spaulding v. Howard, 121 Cal. 194 [53 P. 563]. The commissioner thus appointed derives his authority from the statute and the order of sale. (15 Cal.Jur. 302, sec. 4.) Section 691 of the Code of Civil Procedure, relied upon by respondents, applies to proceeds of a sale under a writ of execution, as distinguished in Southern California Lumber Co. v. Ocean Beach Hotel Co., supra. [6] The funds, therefore, in the sheriff's hands were in his hands as agent of the court in the foreclosure proceeding. They were in custodia legis. Being in custodia legis, they were not subject to attachment or writ of execution. (Bisconer v. Billing, 71 Cal.App. 779 [236 P. 329]; Union Bank & Trust Co. v. Los Angeles County, 2 Cal.App.2d 600 [38 PaCal.2d 442]; North v. Evans, 1 Cal.App.2d 64 [36 PaCal.2d 133].)
 In Clymer v. Willis, 3 Cal. 363 [58 Am. Dec. 414], it was held that money in the hands of the sheriff collected on execution is not a debt due to the plaintiff in execution but is in the custody of the law until properly disposed of, and is not the subject of attachment or garnishment. It was also held in that case that the sheriff cannot attach money collected on execution in his own hands and that if at any time such money is subject to any other process in his hands such process must be executed by the coroner.
 We therefore must conclude that the surplus funds held by the sheriff were not subject to execution. The funds in the sheriff's hands were in his hands as agent of the court in the foreclosure proceeding. He had no power to do anything with such surplus except to return it to the court or hold it as agent for the court subject to its further order, *75 unless he could point to something in the order to justify the exercise of such power. [7] The decree itself recited the fact that appellant's lien or encumbrance (describing the trust deeds) was "subject and subordinate to" the lien of the plaintiff in that action. This in itself should impart notice of such claim to the sheriff. Respondent Shay, therefore, became liable to the parties injured by his action.
 From the stipulated facts it is clear that Schluter, as vice president and director of the debtor corporation and as a party to various other pieces of litigation affecting not only the debtor corporation but also the particular property of the corporation subject to the foreclosure which has been here considered, as well as in his capacity as purchaser of the senior lienholder's interest, cannot claim that he lacked notice of the position of Withington and Nolder in reference to the junior liens or encumbrances.
 In Camp v. Land, 122 Cal. 167 [54 P. 839], it was held (quoting from the syllabus) that "A trust deed is not merged or extinguished in a judgment of foreclosure of a prior mortgage, if no foreclosure of the trust deed was attempted or ordered by the court, and if the bank secured thereby, when made a party to the foreclosure, merely asked for an application of any surplus to the reduction of its debt."
 In Richman v. Bank of Perris, 102 Cal.App. 71 [282 P. 801], at page 88, this court said: "The lien of an execution and attachment proceedings attaches to the real and not to the apparent interest of a judgment debtor in and to his property, and the purchaser at an execution sale takes subject to such existing liens and equities as the property was subject to in the hands of the debtor, unless he can show he purchased the same without notice, either actual or constructive, of the existence of such liens or equities." (Citing cases.)
 The case of Griffith v. List, 122 Cal.App. 125 [9 PaCal.2d 529], upon which respondents mainly rely, involved the question of laches. It was there held that under somewhat similar evidence a lien could not be asserted against the surplus after it had been disbursed pursuant to order of the court and that order had become final; that a delay of 23 months in asserting the claim for the surplus caused the claim to be barred by laches. The holding in that case is not applicable *76 to the facts here involved and therefore not controlling.
 [8] Respondents' additional contention that appellants, being beneficiaries under the trust deeds, are not proper parties plaintiff is untenable. A beneficiary may sue to preserve the trust property or enforce an obligation which exists in favor of the trust estate. (Estate of Finch, 202 Cal. 612 [262 P. 34]; 25 Cal.Jur. 354, sec. 199.) [9] However, this question cannot be raised for the first time on appeal. (2 Cal.Jur. 252, sec. 76.)
 [10] Appellants have established sufficient evidence under the pleadings and prayer for relief authorizing a court of equity to compel respondents to return to the custody of the court the surplus funds wrongfully converted. Appellants' respective rights in and to any such surplus funds held under the foreclosure sale were not fully determined in the foreclosure decree. This question still remains undecided and should be disposed of in an appropriate proceeding before appellants will become entitled to recover a money judgment as prayed for in this action. This does not necessarily apply as to the count for declaratory relief.
 The action to foreclose the mechanic's lien was equitable in its nature. The beneficiaries under the deeds of trust appeared and set up the liens of the deeds of trust.
 As we have said, the surplus remaining from the sale after discharging the mechanic's lien was and still should be in the custody of the court. That being true, the court of equity having jurisdiction over that money may complete its task and determine its proper distribution in the foreclosure proceeding. If the respondents refuse to return the money to the actual custody of the court they may then be compelled to do so.
 The attempted appeal from the order denying the motion for a new trial, not being an appealable order, is dismissed. (Chichester v. Seymour, 28 Cal.App.2d 696 [83 PaCal.2d 301].)
 The judgment is reversed.
 Barnard, P. J., and Marks, J., concurred.
 A petition for a rehearing was denied October 28, 1941 by the District Court of Appeal of the Fourth Appellate District. Respondents' petition for a hearing in the Supreme Court was denied November 27, 1941, and the following opinion was then rendered:
 *77THE COURT.
 The petition for hearing in this court after decision by the District Court of Appeal of the Fourth Appellate District is denied.
 However, such denial should not be considered as an agreement with the following sentence in the opinion: "The code provision relating to the foreclosure of mechanics' liens provides no mode of enforcing a judgment other than by a sale of the property and docketing a deficiency judgment against the defendant who may be liable therefor. (Central L. & M. Co. v. Center, 107 Cal. 193 [40 P. 334].)" In 1911, section 1197 of the Code of Civil Procedure was amended to authorize a personal action to recover a debt due for materials furnished either in connection with the foreclosure of the lien or in a separate suit. (See Wm. J. Bettingen Lbr. Co. v. Kerrin, 99 Cal.App. 686 [279 P. 163].)
