From owner-freebsd-questions Mon Jan 11 07:55:36 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA21378 for freebsd-questions-outgoing; Mon, 11 Jan 1999 07:55:36 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from newmail.scitec.com (newmail.scitec.com [198.138.228.7]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA21373 for ; Mon, 11 Jan 1999 07:55:34 -0800 (PST) (envelope-from postman@newmail.scitec.com) Received: (from postman@localhost) by newmail.scitec.com (8.8.8/8.8.8) id KAA20912 for freebsd-questions@freebsd.org; Mon, 11 Jan 1999 10:56:35 -0500 (EST) (envelope-from postman) From: SciTec Postman Message-Id: <199901111556.KAA20912@newmail.scitec.com> Subject: su in sh scripts To: freebsd-questions@FreeBSD.ORG Date: Mon, 11 Jan 1999 10:56:35 -0500 (EST) Reply-To: cjc@scitec.com Organization: SciTec, Inc. X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I am writing some sh shell scripts to do some basic email administrative duties. For example, someone who is not at all familiar with UNIX might have to go in and change a forwarding address for someone. I do not want to have them clunking around /etc/aliases, and I do not think they want to deal with emacs or vi on a console screen. My scripts are mostly just simple uses of sed and redirection to files to add and remove things from the /etc/aliases. However, I have caught a hitch that reveals my inexperience with shell scripts, especially sh. Many of these scripts send out a confirmation mail. The scripts will be run by root (we typically are changing /etc/aliases), but I do not want to be sending mail from root. What I would like to do is 'su' to another account, execute some commands, then leave the script. However, su likes to spawn new shells. I am not exactly sure the best way to change users in a script and to get commands to the new user's shell. So what I want to know is, what is the most graceful way to execute a couple of commands as another user from a shell script? -- Crist J. Clark postman@scitec.com SciTec, Inc E-Mail Administrator To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message