Sponsored Content
Top Forums Programming Running a script as root in the script Post 303007445 by robertkwild on Thursday 16th of November 2017 04:33:17 PM
Old 11-16-2017
Hi Robin yes im confused, what do you mean sudo_user

do you mean for every command i have in my script put sudo infront of it

then i thought instead of putting sudo infront of every command just make the user type su and job done ie from there it will run all the commands as root
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Run non-root script as root with non-root environment

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)
Discussion started by: bubba112557
2 Replies

2. Shell Programming and Scripting

Running a command or script as root

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)
Discussion started by: rm-r
3 Replies

3. Shell Programming and Scripting

As root , running script as different user with su - problem

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)
Discussion started by: dbsupp
4 Replies

4. Cybersecurity

Running script through SSH as root

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)
Discussion started by: irinotecan
4 Replies

5. Shell Programming and Scripting

Issue running script as root

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)
Discussion started by: cj09
4 Replies

6. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

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)
Discussion started by: damang111
2 Replies

7. Shell Programming and Scripting

Script for running root based C++ code

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)
Discussion started by: nrjrasaxena
12 Replies

8. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

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)
Discussion started by: ketanraut
1 Replies

9. Shell Programming and Scripting

Running a script as root but with different users inside

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)
Discussion started by: nanz143
18 Replies

10. Shell Programming and Scripting

Root running a script calling to scp using user "xyz" is not authenticating!

Close duplicate thread. (0 Replies)
Discussion started by: denissi
0 Replies
SUDOREPLAY(8)						       MAINTENANCE COMMANDS						     SUDOREPLAY(8)

NAME
sudoreplay - replay sudo session logs SYNOPSIS
sudoreplay [-d directory] [-f filter] [-m max_wait] [-s speed_factor] ID sudoreplay [-d directory] -l [search expression] DESCRIPTION
sudoreplay plays back or lists the session logs created by sudo. When replaying, sudoreplay can play the session back in real-time, or the playback speed may be adjusted (faster or slower) based on the command line options. The ID should be a six character sequence of digits and upper case letters, e.g. 0100A5, which is logged by sudo when a command is run with session logging enabled. In list mode, sudoreplay can be used to find the ID of a session based on a number of criteria such as the user, tty or command run. In replay mode, if the standard output has not been redirected, sudoreplay will act on the following keys: ' ' (space) Pause output; press any key to resume. '<' Reduce the playback speed by one half. '>' Double the playback speed. OPTIONS
sudoreplay accepts the following command line options: -d directory Use directory to for the session logs instead of the default, /var/log/sudo-io. -f filter By default, sudoreplay will play back the command's standard output, standard error and tty output. The -f option can be used to select which of these to output. The filter argument is a comma-separated list, consisting of one or more of following: stdout, stderr, and ttyout. -l Enable "list mode". In this mode, sudoreplay will list available session IDs. If a search expression is specified, it will be used to restrict the IDs that are displayed. An expression is composed of the following predicates: command command pattern Evaluates to true if the command run matches command pattern. On systems with POSIX regular expression support, the pattern may be an extended regular expression. On systems without POSIX regular expression support, a simple substring match is performed instead. cwd directory Evaluates to true if the command was run with the specified current working directory. fromdate date Evaluates to true if the command was run on or after date. See "Date and time format" for a description of supported date and time formats. group runas_group Evaluates to true if the command was run with the specified runas_group. Note that unless a runas_group was explicitly specified when sudo was run this field will be empty in the log. runas runas_user Evaluates to true if the command was run as the specified runas_user. Note that sudo runs commands as user root by default. todate date Evaluates to true if the command was run on or prior to date. See "Date and time format" for a description of supported date and time formats. tty tty Evaluates to true if the command was run on the specified terminal device. The tty should be specified without the /dev/ prefix, e.g. tty01 instead of /dev/tty01. user user name Evaluates to true if the ID matches a command run by user name. Predicates may be abbreviated to the shortest unique string (currently all predicates may be shortened to a single character). Predicates may be combined using and, or and ! operators as well as '(' and ')' for grouping (note that parentheses must generally be escaped from the shell). The and operator is optional, adjacent predicates have an implied and unless separated by an or. -m max_wait Specify an upper bound on how long to wait between key presses or output data. By default, sudo_replay will accurately reproduce the delays between key presses or program output. However, this can be tedious when the session includes long pauses. When the -m option is specified, sudoreplay will limit these pauses to at most max_wait seconds. The value may be specified as a floating point number, .e.g. 2.5. -s speed_factor This option causes sudoreplay to adjust the number of seconds it will wait between key presses or program output. This can be used to slow down or speed up the display. For example, a speed_factor of 2 would make the output twice as fast whereas a speed_factor of <.5> would make the output twice as slow. -V The -V (version) option causes sudoreplay to print its version number and exit. Date and time format The time and date may be specified multiple ways, common formats include: HH:MM:SS am MM/DD/CCYY timezone 24 hour time may be used in place of am/pm. HH:MM:SS am Month, Day Year timezone 24 hour time may be used in place of am/pm, and month and day names may be abbreviated. Note that month and day of the week names must be specified in English. CCYY-MM-DD HH:MM:SS ISO time format DD Month CCYY HH:MM:SS The month name may be abbreviated. Either time or date may be omitted, the am/pm and timezone are optional. If no date is specified, the current day is assumed; if no time is specified, the first second of the specified date is used. The less significant parts of both time and date may also be omitted, in which case zero is assumed. For example, the following are all valid: The following are all valid time and date specifications: now The current time and date. tomorrow Exactly one day from now. yesterday 24 hours ago. 2 hours ago 2 hours ago. next Friday The first second of the next Friday. this week The current time but the first day of the coming week. a fortnight ago The current time but 14 days ago. 10:01 am 9/17/2009 10:01 am, September 17, 2009. 10:01 am 10:01 am on the current day. 10 10:00 am on the current day. 9/17/2009 00:00 am, September 17, 2009. 10:01 am Sep 17, 2009 10:01 am, September 17, 2009. FILES
/var/log/sudo-io The default I/O log directory. /var/log/sudo-io/00/00/01/log Example session log info. /var/log/sudo-io/00/00/01/stdin Example session standard input log. /var/log/sudo-io/00/00/01/stdout Example session standard output log. /var/log/sudo-io/00/00/01/stderr Example session standard error log. /var/log/sudo-io/00/00/01/ttyin Example session tty input file. /var/log/sudo-io/00/00/01/ttyout Example session tty output file. /var/log/sudo-io/00/00/01/timing Example session timing file. Note that the stdin, stdout and stderr files will be empty unless sudo was used as part of a pipeline for a particular command. EXAMPLES
List sessions run by user millert: sudoreplay -l user millert List sessions run by user bob with a command containing the string vi: sudoreplay -l user bob command vi List sessions run by user jeff that match a regular expression: sudoreplay -l user jeff command '/bin/[a-z]*sh' List sessions run by jeff or bob on the console: sudoreplay -l ( user jeff or user bob ) tty console SEE ALSO
sudo(8), script(1) AUTHOR
Todd C. Miller BUGS
If you feel you have found a bug in sudoreplay, please submit a bug report at http://www.sudo.ws/sudo/bugs/ SUPPORT
Limited free support is available via the sudo-users mailing list, see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives. DISCLAIMER
sudoreplay is provided ``AS IS'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. See the LICENSE file distributed with sudo or http://www.sudo.ws/sudo/license.html for complete details. 1.7.4 July 12, 2010 SUDOREPLAY(8)
All times are GMT -4. The time now is 07:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy