Sponsored Content
Top Forums Shell Programming and Scripting Execute a command with root user Post 302987965 by rbatte1 on Monday 19th of December 2016 08:00:31 AM
Old 12-19-2016
Additionally, if you run this:-
Code:
sudo cat /tmp/tmp.file >>/etc/logger

... what you are trying to do is to run cat with privileges so it can open whatever file out want, HOWEVER the >> is in your current, non-privileged shell so if you cannot open the file, then you will get the bash: /etc/logger: Permission denied seen in post 1

You haven't answered vbe's question about what /etc/logger is. Is this just a plain log file, or are you trying to write to the system logs? If it is the latter, overwriting/appending to it would be a bad thing. Usually /etc contains configuration information that you would not want to routinely overwrite/append. Depending on your actual desires, this is more likely to be a file in /var somewhere.

What are you actually trying to achieve?



Robin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Maint user cannot execute ping command

I want give rights for the maint user to execute the "ping" command. Currently root user can execute the "ping" command, but the maint user is not able to execute the command. (3 Replies)
Discussion started by: kabeer_n
3 Replies

2. Shell Programming and Scripting

shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out? #!/usr/bin/ksh test="cal > /tmp/tmp.txt 2>&1" $test I know it will work for the following format: #!/usr/bin/ksh cal > /tmp/tmp.txt 2>&1 However, I need to get the command from the user in... (1 Reply)
Discussion started by: redtiger
1 Replies

3. Shell Programming and Scripting

login into root from user and execute command through script

i have logged in as user. I want to write a script to login into root and execute commands for eg. ifconfig or other command. kindly help me out. (6 Replies)
Discussion started by: pradeepreddy
6 Replies

4. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

5. UNIX for Dummies Questions & Answers

Allow a user use a specific root command!

Hi, I like to allow an user to permit an root command " /usr/ucb/ps -auxwww", do you know how? Kind regards Mehrdad (6 Replies)
Discussion started by: mehrdad68
6 Replies

6. Shell Programming and Scripting

Execute Root command as Normal user

Hi, We need to execute a root commmand to change the expiry period of a user but we are getting error as permission denied Q How can we execute a root command by a normal user ? :mad: any thing or suggestion will be good .... :b: (3 Replies)
Discussion started by: abhishek1979
3 Replies

7. Shell Programming and Scripting

How to take input from the user from the command line and execute commands basedon that?

Hi, I am using solaris 10 and bash shell.Script execution follows below.Initially it will check whether a directory exists or not if does not exist it will create it.(This I have completed) Second step:I have four users say user1,user2,user3,user4.Script should prompt for the user id and... (11 Replies)
Discussion started by: muraliinfy04
11 Replies

8. UNIX for Dummies Questions & Answers

Execute a command as root from normal user

Hi , I am trying to stop and start a process using the below code. I have sudo access on my machine ## PID = process id echo "$PASSWD" | sudo -S kill -9 <PID> echo "$PASSWD" | sudo -S /opt/abc/startserver /opt/abc/startserver: error while loading shared libraries: librts.so: cannot open... (6 Replies)
Discussion started by: rakeshkumar
6 Replies

9. UNIX for Beginners Questions & Answers

Running a command as another non-root user

Hi, I am trying to run a command within my KSH script as another user due to permission issues, now both users are non root. I have tried the following command and was unsuccessful: echo "<password>" | sudo -S -u <username> -k command Can I use sudo to run a command as a non-root user? (5 Replies)
Discussion started by: MIA651
5 Replies

10. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies
logger::appender(3tcl)					 Object Oriented logging facility				    logger::appender(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
logger::appender - Collection of predefined appenders for logger SYNOPSIS
package require Tcl 8.2 package require logger::appender ?1.2? ::logger::appender::console -level level -service service ?options...? ::logger::appender::colorConsole -level level -service service ?options...? _________________________________________________________________ DESCRIPTION
This package provides a predefined set of logger templates. ::logger::appender::console -level level -service service ?options...? -level level Name of the level to fill in as "priority" in the log procedure. -service service Name of the service to fill in as "category" in the log procedure. -appenderArgs appenderArgs Any additional arguments for the log procedure in list form -conversionPattern conversionPattern The log pattern to use (see logger::utils::createLogProc for the allowed substitutions). -procName procName Explicitly set the name of the created procedure. -procNameVar procNameVar Name of the variable to set in the calling context. This variable will contain the name of the procedure. ::logger::appender::colorConsole -level level -service service ?options...? See ::logger::appender::colorConsole for a description of the applicable options. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category logger of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
appender, logger CATEGORY
Programming tools COPYRIGHT
Copyright (c) 2005 Aamer Akhter <aakhter@cisco.com> log 1.2 logger::appender(3tcl)
All times are GMT -4. The time now is 07:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy