Sponsored Content
Full Discussion: output and error redirection
Top Forums Shell Programming and Scripting output and error redirection Post 302344963 by jpriyank on Tuesday 18th of August 2009 05:44:27 AM
Old 08-18-2009
Data output and error redirection

hi Smilie

if condition >&- 2>&-

Can anybody explain the redirection in above command


Thanks in advance
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

redirection of ladebug output

i am using a command line ladebug debugger. i want to redirect the responses of the debugger to a text file but run args > output-file syntax does not successful because it redirects only the standard out of the binary that i am examining, but i want the debuggers own responses like "stopped... (2 Replies)
Discussion started by: yakari
2 Replies

2. UNIX for Dummies Questions & Answers

output redirection in scripts

I am trying to write a script that will remove any line in 2 given text files starting with '-'. the output should be to the second file. this is what I tried: #!/bin/csh -f cat $1 $2 | grep -v '^-' > $2 the problem is the after executing the script, file2 contains only the lines from... (7 Replies)
Discussion started by: stewie griffin
7 Replies

3. Shell Programming and Scripting

redirection output in two files

I want to redirect output of my script to two logfiles. I tried this : ./run.sh -c APP | tee >(grep " " > AppLogs.log) >(grep "XYZ" > xyz.log) >dev/null but this does not solve my purpose because logfile xyz.log remains empty untill i stop my script, i want both files, AppLogs.log and... (4 Replies)
Discussion started by: cmdup
4 Replies

4. Shell Programming and Scripting

redirection and output

I'm redirecting the output of a command to a logfile, however, if the user is on a terminal I would also like the output to be displayed on the screen. tar tvf some_tarfile >Logfile if the user is on a term then have the output to the Logfile and also be displayed on the screen at the same... (2 Replies)
Discussion started by: nck
2 Replies

5. Shell Programming and Scripting

Redirection output

Hi there I have a script that runs but it outputs everything onto the screen instead of a file. I've tried using the > outputfile.txt however all it does is dump the output to the screen and creates an outputfile.txt but doesn't put anything in that file. Any help would be appreciated ... (6 Replies)
Discussion started by: kma07
6 Replies

6. Shell Programming and Scripting

Output redirection

We have an application here that does some table queries and then prints the result on screen. I do not have the code of this application (which i will just call "queryCommand"), but what it does is that you call it with some parameters and it prints some info about the query and then the... (5 Replies)
Discussion started by: jolateh
5 Replies

7. UNIX for Dummies Questions & Answers

Output redirection

Hello i am trying to write a script that will redirect the output to a certain file. Here is the code so far: #!/bin/bash ps -e | sort | more > psfile When I execute the script nothing happens since i assume the output was redirected to the file called psfile. When I try to look at the... (1 Reply)
Discussion started by: mfruiz34
1 Replies

8. Shell Programming and Scripting

Redirection of ls -l output

Hi I am making a script where i want to redirect the output of ls -l to a file Example #ls -l fil1.txt > /opt/temp/a.txt ac: No such file or directory I want to capture output of this command like here output is ac: No such file or directory can anyone help (4 Replies)
Discussion started by: anish19
4 Replies

9. Shell Programming and Scripting

output redirection

Hi all I was wondering if there was a slicker way of doing this without the file - awk '{print $2}' FS=":" "${FILE}" > "${TMPFILE}" { read M_GRP_ID || m_fail 1 "Error: Read failed 1 (${FUNCNAME})" read M_GRP_WAIT || m_fail 1 "Error: Read failed 2 (${FUNCNAME})" }... (6 Replies)
Discussion started by: steadyonabix
6 Replies

10. Shell Programming and Scripting

Conditional output redirection

Hi there, I'm in a coding mood! I've come through many ways of conditionally redirect the output of a script like: ] || exec &> /dev/nullBut my goal is slightly different. I would like to conditionally redirect the output of a command depending on the status of the command itself: if !... (6 Replies)
Discussion started by: chebarbudo
6 Replies
exec(1) 							   User Commands							   exec(1)

NAME
exec, eval, source - shell built-in functions to execute other commands SYNOPSIS
sh exec [argument]... eval [argument]... csh exec command eval argument... source [-h] name ksh *exec [argument]... *eval [argument]... ksh93 +exec [-c] [-a name] [command [argument ... ]] +eval [argument]... DESCRIPTION
sh The exec command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments and appear and, if no other arguments are specified, cause the shell input/output to be modified. The arguments to the eval built-in are read as input to the shell and the resulting command(s) executed. csh exec executes command in place of the current shell, which terminates. eval reads its arguments as input to the shell and executes the resulting command(s). This is usually used to execute commands generated as the result of command or variable substitution. source reads commands from name. source commands can be nested, but if they are nested too deeply the shell can run out of file descrip- tors. An error in a sourced file at any level terminates all nested source commands. -h Place commands from the file name on the history list without executing them. ksh With the exec built-in, if arg is specified, the command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments can appear and affect the current process. If no arguments are specified the effect of this command is to modify file descriptors as prescribed by the input/output redirection list. In this case, any file descriptor numbers greater than 2 that are opened with this mechanism are closed when invoking another program. The arguments to eval are read as input to the shell and the resulting command(s) executed. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera- tion are not performed. ksh93 exec is a special built-in command that can be used to manipulate file descriptors or to replace the current shell with a new command. If command is specified, then the current shell process is replaced by command rather than running command and waiting for it to complete. There is no need to use exec to enhance performance since the shell implicitly uses the exec mechanism internally whenever possible. If no operands are specified, exec can be used to open or close files, or to manipulate file descriptors from 0 to 9 in the current shell environment using the standard redirection mechanism available with all commands. The close-on-exec flags is set on file descriptor numbers greater than 2 that are opened this way so that they are closed when another program is invoked. Because exec is a special command, any failure causes the script that invokes it to exit. This can be prevented by invoking exec from the command utility. exec cannot be invoked from a restricted shell to create files or to open a file for writing or appending. eval is a shell special built-in command that constructs a command by concatenating the arguments together, separating each with a space. The resulting string is taken as input to the shell and evaluated in the current environment. command words are expanded twice, once to construct argument, and again when the shell executes the constructed command. It is not an error if argument is not specified. On this manual page, ksh93 commands that are preceded by one or two + symbols are special built-in commands and are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. They are not valid function names. 5. Words following a command preceded by ++ that are in the format of a variable assignment are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and field splitting and file name genera- tion are not performed. OPTIONS
ksh93 The following options are supported by ksh93 exec: -a name argv[0] is set to name for command. -c Clear all environment variables before executions except variable assignments that are part of the current exec command. EXIT STATUS
ksh The following exit values are returned by exec: 0 Successful completion. 1-125 A redirection error occurred. 127 command was not found. 126 command was found, but it is not an executable utility. ksh93 The following exit values are returned by exec. If command is specified, exec does not return. 0 Successful completion. All I/O redirections were successful. >0 An error occurred. The following exit values are returned by eval: If argument is not specified, the exit status is 0. Otherwise, it is the exit status of the command defined by the argument operands. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), ksh(1), ksh93(1), sh(1), attributes(5) SunOS 5.11 8 Apr 2008 exec(1)
All times are GMT -4. The time now is 01:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy