From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653644221647.tru64-unix-managers.marc@archive.invalid> From: Daniel Clar Date: Mon, 10 Dec 2001 06:18:10 +0000 To: tru64-unix-managers Subject: SUMMARY: su - in a command file X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653644221647 The original posting was : > Hello Managers, > > Under the root account I want to create a COMMAND file in which there is > a su - USER command. > > This file will be executed during the night with an at time COMMAND to > do some management tasks. My current problem is thatv the environment > and in particular the shell are not currently set when it's executed. > > An rsh -l USER command is doing some job but not the shell modification. Thank you to all for their answers I give underwith. After reading them the ebst solution for me was to modify COMMAND file to be written in the good shell. Daniel _________________________________________________________ Kurt Carlson ------------------------------------- Something like the following should work: su - USER -c "COMMAND" Another alternative is to stick with rsh, but execute a script under USER and have the script look for an env variable set by .profile and if not found execute it, ksh syntax: if [ -n "$VARIABLE" ]; then . ~/.profile; fi If you also use a .kshrc or equivalent you may want to run that, too. Peacock Dennis - dpeaco -------------------------------------------------------------- Wouldn't it be "much" easier to simply create a crontab job for this? Each user "can" have their own crontab file to do with as they please, to include running jobs at particular times. If you have root access and you want to, you can create the crontab file "for" that user...i.e. crontab -e daniel will create a file in /usr/spool/cron/crontabs directory and you can edit that to "call" your script(s) at designated times....this way the script or job will be ran with "that" users ID and not root...... "Mehall, Michael R." ---------------------------------------------------------------- If I understand your problem correctly, it is that the environment variables are not being set. This is true when you run cron or at jobs. The best way to take care of this is to set the environment variables in the job itself (if it's a script), or run whatever jobs you are running from a "wrapper" script and set the environment variables there before running the real job. Hope this helps! ------------------------- What I normally do is (1) make a shell script out of the tasks to be performed as the other user; this script is responsible for setting its own shell (#!) and environment. (2) run this script either with su USER -c /path/name/to/script, or through sudo. Jeff Borah , James Sainsbury ,John Tan ------------------------------------------------------------------------------------------------------- Try; su -c user command