Sponsored Content
Top Forums UNIX for Advanced & Expert Users Syntax when using the 'exec' command Post 302985381 by Corona688 on Tuesday 8th of November 2016 05:28:28 PM
Old 11-08-2016
Quote:
how can i automate -- inside of the script -- for stdout and stderr to be re-directed to the same file, something that usually requires entering an admin password.
That is easy.

Code:
exec 1>filename
exec 2>&1

echo "from stderr" >&2
echo "from stdout"

None of the above requires root... I think you will discover that the problem is not exec -- the problem is the file itself. Perhaps the file is owned by root, preventing you from writing to it? Show ls -l filename please.

If your script runs with insufficient permissions, it cannot get more. Period. Full stop.

Either run it with sufficient permissions or fix the file so it doesn't need extra permissions.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using the -exec command

linux redhat 8.0 I am getting accustomed to using the -exec command to get around my databse.. and use it to edit and update files..! is this more apllicable than jumping from one directory to the other.. I have set up the databse so that the inode #'s are accessable and can get me from one... (0 Replies)
Discussion started by: moxxx68
0 Replies

2. Shell Programming and Scripting

exec command

hai i want know the difference between two shell scripts those are 1) a=2004 echo $a #output------2004 exec < inputfile while read line do echo $a #output-------2004 a=2005 echo $line echo $a ... (1 Reply)
Discussion started by: g_s_r_c
1 Replies

3. UNIX for Dummies Questions & Answers

Need help with -exec cp command.

I have a ksh script that contains the following: find /dir1/dir2 -type f -name "FILE.*" -newer /dir1/dir2/afterme.txt -exec cp /dir1/dir2/dir3 {} \; When I run it from the cli, it runs fine. When I run it from the ksh script I get find: missing argument to `-exec' I also tried -exec cp... (40 Replies)
Discussion started by: bbbngowc
40 Replies

4. Shell Programming and Scripting

exec command

can any one pls explain the meaning of exec 1<&5 ?? its urgent (2 Replies)
Discussion started by: santosh1234
2 Replies

5. Shell Programming and Scripting

exec command help

All, I am using below shell script to output the content to outputfile.txt. What I am looking for is in addition to outputfile.txt, I want the output to be on standard output too. exec > outputfile.txt echo "Starting " echo "ending" (5 Replies)
Discussion started by: basic_shell
5 Replies

6. Shell Programming and Scripting

exec command

How can I use the exec command to log my korn shell session to the screen and the log file? Currently I have this command: $exec 1> ${LOG} 2>&1 This logs the output to the log file only. I want it to go to the screen also. Is this possible with this command? thanks. (10 Replies)
Discussion started by: djehresmann
10 Replies

7. UNIX for Dummies Questions & Answers

Exec command

Hi can some one explain the following command , It would really help if some can really elloborate on what is happening out here export PATH | exec /bin/sh ./auto_approve :q P.S: This is the first time i am using exec ,so an elloboration what does it do and what is the use of the :q will be... (1 Reply)
Discussion started by: Sri3001
1 Replies

8. Shell Programming and Scripting

exec command help

Hi, I have the following lines in a script : . . exec < some_file . . . I have very little idea about exec command. I would like to know what this does and what will happen if the file some_file does not exist. Specifically, I would like to know whether the lines following this... (5 Replies)
Discussion started by: elixir_sinari
5 Replies

9. Shell Programming and Scripting

Exec command - what is it doing here?

Hi all, Forgive me for asking for help with my first post, but I am struggling here. I've been asked to translate a bash script into a Windows script (probably batch or powershell, not sure yet), so the first step is obviously understand what the bash script is doing. But I have no experience in... (5 Replies)
Discussion started by: el_foz
5 Replies

10. Shell Programming and Scripting

Linux find command seems to not transmit all the result to the '-exec command'

Hello. From a script, a command for a test is use : find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc' Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies
sulogin(8)						      System Manager's Manual							sulogin(8)

NAME
sulogin - single-user login program (Enhanced Security) SYNOPSIS
/sbin/sulogin DESCRIPTION
The sulogin program is run by the init process on the console terminal when entering single-user mode. The sulogin program checks the sys- tem configuration to determine whether entering single-user mode requires entering the root password. If it does not, then sulogin execs /sbin/sh with its argv[0] set to "-". That same exec is also done if the root password is correctly entered. The decision to enter the single-user mode depends on the state of the system configuration files. If the files cannot be read, then defaults are assumed (as described below). Therefore, the loss of a configuration file does not prevent access to the system console for repairing the problem. The sulogin program first checks the /etc/rc.config file for a the SECURE_CONSOLE variable. If such a variable is present, and it is set to a true value (either "TRUE", "ON", "YES", or "1"), then the program asks for the root password. The value of the SECURE_CONSOLE vari- able is checked in a case-independent fashion, and only a minimal match is necessary. Thus, the value is really checked against the fol- lowing regular expression: ^([Tt]|1|[Yy]|[Oo][Nn]).* If the SECURE_CONSOLE variable is present, but does not have one of the true values, then sulogin does not ask for the root password, but simply execs /sbin/sh as previously described. If the SECURE_CONSOLE variable is not found in the /etc/rc.config file, or if that file is missing or unreadable, then an attempt is made to obtain the value of the console firmware setting of the SECURE variable, using the GSI_PROM_ENV function of the getsysinfo() system call. If the check determines the console commands are password- protected, the sulogin program requests the root password. If sulogin has made the decision to request the root password, it also determines whether BASE or ENHANCED security should be used to vali- date that password. This is done using the value of the SECURITY variable from the /etc/rc.config file, unless that file was not readable, in which case the /etc/sia/matrix.conf file is read, looking for a line beginning with the string "siad_ses_init=", and containing either "(OSFC2," or "(BSD,". If the /etc/rc.config file was readable, but the SECURITY variable was not set, then BASE security is assumed. (This is how the /sbin/init.d/security script initializes the /etc/sia/matrix.conf file, as well). If the /etc/rc.config file can not be read and the /etc/sia/matrix.conf file either can not be read or does not have an appropriate siad_ses_init line, then the sulogin program checks to see whether the /etc/passwd file contains a valid entry for root and whether the getespwnam("root") function returns a valid extended profile. If both profile entries exist, but only one has a valid encrypted password field, that profile (and thus that security policy) is used. If both passwords are valid, the BASE security policy is used. Once the sulogin program has determined which security policy to use, it checks whether that policy has a valid account entry for user root (if not already checked while determining which policy to use), and whether that entry has a password that can be matched. If the password is impossible to match, or if no valid root profile exists, then sulogin prints a warning and execs /sbin/sh as previously described. For BASE security, a null encrypted password field for root causes the program to exec /sbin/sh without complaining. If there is a matchable root password, sulogin prints out "Single-user root login" and prompts for the password. If the entered password does not match (after the appropriate encryption if non-null), the program waits for 5 seconds (to deter break-in attempts, displays "Sorry", and re-prompts. If the program is interrupted or receives and end-of-file condition while attempting to read a password from the console terminal, it simply exits. This normally causes init to enter multi-user mode (It depends on system configuration information in /etc/inittab, specifically the entry marked with "initdefault", which ships at run-level "3"). This may also cause init to prompt for a run level, or to restart the sulogin program. Finally, if a password was collected, and it did match, the exec of /sbin/sh is done. If that exec fails, the reason for the failure is displayed, and the program sleeps for 5 seconds before exiting. Upon exiting control of the console is returned to the init process, as previously described for interrupt or end-of-file. FILES
/etc/rc.config /etc/sia/matrix.conf /etc/passwd /tcb/files/auth.db (/tcb/files/auth/r/root) RELATED INFORMATION
login(1), getpwnam(3), getespwnam(3), dispcrypt(3), matrix.conf(4), init(8) Security delim off sulogin(8)
All times are GMT -4. The time now is 12:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy