Date: Mon, 11 Jan 1999 10:56:35 -0500 (EST) From: SciTec Postman <postman@scitec.com> To: freebsd-questions@FreeBSD.ORG Subject: su in sh scripts Message-ID: <199901111556.KAA20912@newmail.scitec.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901111556.KAA20912>