sudo is not a shell and therefore does not understand redirection (>>/etc/logger) and when you pass the command cat /tmp/tmp.file >>/etc/logger to it in quotes, it sees >>/etc/logger as part of the command name. Instead what you could do is use sudo to run a shell who does this for you:
Similar to what Corona688 suggested, if cat /tmp/tmp.file >>/etc/logger is part of a shell script, then you could use sudo /path/to/script to make it happen, since running a script will invoke a new shell that will run as root and that will interpret that shell script.
Last edited by Scrutinizer; 12-17-2016 at 01:44 AM..
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT MOJAVE
logger
LOGGER(1) BSD General Commands Manual LOGGER(1)NAME
logger -- make entries in the system log
SYNOPSIS
logger [-is] [-f file] [-p pri] [-t tag] [message ...]
DESCRIPTION
Logger provides a shell command interface to the syslog(3) system log module.
Options:
-i Log the process id of the logger process with each line.
-s Log the message to standard error, as well as the system log.
-f file Log the specified file.
-p pri Enter the message with the specified priority. The priority may be specified numerically or as a ``facility.level'' pair. For
example, ``-p local3.info'' logs the message(s) as informational level in the local3 facility. The default is ``user.notice.''
-t tag Mark every line in the log with the specified tag.
message Write the message to log; if not specified, and the -f flag is not provided, standard input is logged.
The logger utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
logger System rebooted
logger -p local0.notice -t HOSTIDM -f /dev/idmc
SEE ALSO syslog(3), syslogd(8)STANDARDS
The logger utility conforms to IEEE Std 1003.2-1992 (``POSIX.2'').
4.3 Berkeley Distribution June 6, 1993 4.3 Berkeley Distribution