The command id -u root will return the string 0 on any UNIX system. The current real or effective UID of the person running the script has no effect on the results produced by this command.
The test command [ id -u root -ne 0 ] does not run the id command; it invokes test with the five arguments id, -u, root, -ne, and 0. And that is not a valid set of arguments to be given to the test utility.
Nothing in your script after invoking su will be run with root privileges. The su utility, if given a proper password, will start a shell and nothing in the rest of your script will be run until that shell exits.
If you were running the id command, the exit code of that utility is not related to the uid or euid of the user running the process; it only tells you whether or not the user you name with the -u option is known on your system.
Would something more like:
where command_file is the pathname of a file containing the commands you want this script to run with root privileges.
All,
I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)
I'm writing an application (Progress language) that needs to:
1) load the contents of a cron table into the Progress application;
2) display this information in a human manner and allow a select group of people to update it (these people are logged in as themselves, not as root);
3) save... (3 Replies)
Dear All
I am running into a situation where I am running a script as another user lets say oracle using su command as below, and the script fails because the .profile of oracle is not executed so the environment variables are not set.
cat /etc/passwd | grep oracle... (4 Replies)
Hi all,
I have a situation where I have a shell script that I need to run remotely on multiple *nix machines via SSH. Unfortunately, some of the commands in it require root access. I know that best practices for ssh entail configuring it so that the root account cannot log in, you need to... (4 Replies)
1) Environment:Red Hat Linux, bash shell
Script to be run owned by user :myUser
Home environment of myUser: pathto/home
2) ESP agent with root access will run
JobXXX.sh
su - myUser -c "/pathto/home/bin/script.sh"
where script.sh has some echo statements and an exit statement in the end... (4 Replies)
So I have a script that runs as a non-root user, lets say the username is 'xymon' .
This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root.
in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Hi all,
I have to run C++ file using root programming, using following commands:
$root -l
root .L TwoTrees.C++
root TwoTrees t
root t.Loop()
root.q
I wonder if I can write script to do the following.
Thanks
Pooja (12 Replies)
I am using blow script :--
#!/bin/bash
FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not
if
then
# echo "process found"
exit 0;
else
echo "process not found"
exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Hi All, my script.sh has the below lines, and i need to run the script as root or wam. please tell me if this will work
#!/bin/bash
sudo -t wam /usr/local/wam/stopwam -r ------- this needs run as wam user
/usr/local/web/stopweb -a --- this needs to run as... (18 Replies)
CHROOT(8) BSD System Manager's Manual CHROOT(8)NAME
chroot -- change root directory
SYNOPSIS
chroot [-u -user] [-g -group] [-G -group,group,...] newroot [command]
DESCRIPTION
The chroot command changes its root directory to the supplied directory newroot and exec's command, if supplied, or an interactive copy of
your shell.
If the -u, -g or -G options are given, the user, group and group list of the process are set to these values after the chroot has taken
place. See setgid(2), setgroups(2), setuid(2), getgrnam(3) and getpwnam(3).
Note, command or the shell are run as your real-user-id.
ENVIRONMENT
The following environment variable is referenced by chroot:
SHELL If set, the string specified by SHELL is interpreted as the name of the shell to exec. If the variable SHELL is not set, /bin/sh is
used.
SEE ALSO chdir(2), chroot(2), environ(7)HISTORY
The chroot utility first appeared in 4.4BSD.
SECURITY CONSIDERATIONS
chroot should never be installed setuid root, as it would then be possible to exploit the program to gain root privileges.
4.3 Berkeley Distribution October 6, 1998 4.3 Berkeley Distribution