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 <kcarlson_at_arsc.edu>
-------------------------------------
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 <Dennis.Peacock_at_acxiom.com>
--------------------------------------------------------------
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
<return> 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." <michael_r_mehall_at_md.northgrum.com>
----------------------------------------------------------------
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!
<sysadmin_at_astro.su.se>
-------------------------
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 <jeff_at_snyfarvg.cc.farmingdale.edu>, James Sainsbury
<J.Sainsbury_at_chem.usyd.edu.au>,John Tan <John.Tan_at_asx.com.au>
-------------------------------------------------------------------------------------------------------
Try; su -c user command
Received on Mon Dec 10 2001 - 06:20:23 NZDT