[FOLEY, HOAG & ELIOT LLP LETTERHEAD] EX 5.1 April 15, 1997 PRI Automation, Inc. 805 Middlesex Turnpike Billerica, Massachusetts 01821 Ladies and Gentlemen: We are familiar with the Registration Statement on Form S-8 (the "S-8 Registration Statement") filed today by PRI Automation, Inc., a Massachusetts corporation (the "Company"), with the Securities and Exchange Commission under the Securities Act of 1933, as amended. The S-8 Registration Statement relates to the proposed offering by the Company of 300,000 shares (the "Shares") of its Common Stock, $0.01 par value per share ("Common Stock"), issuable pursuant to the Company's 1994 Incentive and Nonqualified Stock Option Plan (the "Stock Option Plan"). In arriving at the opinion expressed below, we have examined and relied on the following documents: 1. The Restated Articles of Organization and the Amended and Restated By-Laws of the Company. 2. The records of meetings and consents of the Board of Directors and stockholders of the Company provided to us by the Company. 3. The Stock Option Plan. In addition, we have examined and relied on the originals or copies certified or otherwise identified to our satisfaction of all such corporate records of the Company and such other instruments and other certificates of public officials, officers and representatives of the Company and such other persons, and we have made such investigations of law, as we have deemed appropriate as a basis for the opinions expressed below. Based upon the foregoing, it is our opinion that: 1. The Company has corporate power adequate for the issuance of the Shares in accordance with the S-8 Registration Statement. 2. The Company has taken all necessary corporate action required to authorize the issuance and sale of the Shares. 3. When certificates for the Shares have been duly executed and counter- signed, and delivered against due receipt of the exercise price for the Shares as described in the options relating thereto and the Stock Option Plan, the Shares will be legally-issued, fully-paid and non-assessable. We hereby consent to the filing of this opinion as an exhibit to the S-8 Registration Statement. Very truly yours, FOLEY, HOAG & ELIOT LLP By:/s/ Robert W. Sweet, Jr. --------------------------------------- a partner