Sponsored Content
Top Forums Shell Programming and Scripting can't redirect stderr in bash Post 302151503 by lumix on Saturday 15th of December 2007 09:53:39 PM
Old 12-15-2007
can't redirect stderr in bash

Consider:

#!/bin/sh
#this is a shell script in sh (bourne)
grep missingfile 2>errout.txt

It works from the command line, but keeps producing errors from the script. So how do I redirect in a bash shell...or bourne?

Last edited by lumix; 12-15-2007 at 11:14 PM.. Reason: wrong info
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect stdout and stderr

How can I redirect and append stdout and stderr to a file when using cron? Here is my crontab file: */5 * * * * /dir/php /dir/process_fns.php >>& /dir/dump.txt Cron gives me an 'unexpected character found in line' when trying to add my crontab file. Regards, Zach Curtis POPULUS (8 Replies)
Discussion started by: zcurtis
8 Replies

2. Shell Programming and Scripting

redirect stderr to dev/null in bash env.

Working in a bash environment, in the following example, how do I direct the error message that putting in an invalid flag (-j for example) would normally produce to dev/null? while getopts "abcd" opt do case "$opt" in i) a etc ;; r) b etc ;; f) c etc ;; v) d... (7 Replies)
Discussion started by: Sniper Pixie
7 Replies

3. Shell Programming and Scripting

how can i redirect stderr to file in Make?

Hello all im using tcsh shell on sun Solaris , using the Make utility for compilation i will like to be able to redirect the stderr to file , how can it be done ? (0 Replies)
Discussion started by: umen
0 Replies

4. Shell Programming and Scripting

how to redirect stderr from top with csh

Hello all im trying to use top program in my csh shell like this : set topResult = `top | grep server.exe` but im facing 2 problems 1.when the top program dont installed in the machine im getting error so can i check in csh if application im using exist 2 the top program gives... (2 Replies)
Discussion started by: umen
2 Replies

5. Shell Programming and Scripting

How to redirect stderr and stdout to a file

Hi friends I am facing one problem while redirecting the out of the stderr and stdout to a file let example my problem with a simple example I have a file (say test.sh)in which i run 2 command in the background ps -ef & ls & and now i am run this file and redirect the output to a file... (8 Replies)
Discussion started by: sushantnirwan
8 Replies

6. UNIX for Dummies Questions & Answers

Redirect just stderr to a file with a timestamp

I'm using below command to redirect stderr to a file but I also want to add timestamp to stderr.out to find out the date / time the error occurred. ls -ltr 2>>/tmp/stderr.out Thanks (5 Replies)
Discussion started by: mbak
5 Replies

7. Shell Programming and Scripting

How to redirect the STDERR to a variable in perl?

in my perl script i tried the below statement $result = `cleartool rmstream -f $s1 1> /dev/null`; so as to redirect then error messages,when i print the $result ,it seems to be Null. (4 Replies)
Discussion started by: ram_unx
4 Replies

8. Red Hat

Redirect STDOUT and STDERR of chsh

EDIT: Nevermind, figured it out! Forgot to put backslashes in my perl script to not process literals! Hi everyone. I am trying to have this command pass silently. (no output) chsh -s /bin/sh news Currently it outputs. I've tried.... &> /dev/null 1> /dev/null 2>&1 /dev/null 1>&2... (1 Reply)
Discussion started by: austinharris43
1 Replies

9. Shell Programming and Scripting

How to redirect stderr to a file as well

Hello everyone, I'm a nooby in Linux, and I need some help. I have a shell script like this: echo "Start of script" > ../My_Log_Dir/Script_Name.log .. cp ../My_DataIn/File.txt ../My_DataOut/ 2>> ../My_Log_Dir/Script_Name.log rc=$? .. echo "End of Script" >>... (5 Replies)
Discussion started by: H.Faria
5 Replies

10. Shell Programming and Scripting

Redirect string from bash stderr to user stdin

Hi there, I need to execute a command in the bash. The program prints some standard (output and) error and then wants the user to choose one of several options and type the according input. I am trying to solve this issue in a bash script but also running into some circular dependency. How can I... (7 Replies)
Discussion started by: fredestet
7 Replies
CHECKBASHISMS(1)					      General Commands Manual						  CHECKBASHISMS(1)

NAME
checkbashisms - check for bashisms in /bin/sh scripts SYNOPSIS
checkbashisms script ... checkbashisms --help|--version DESCRIPTION
checkbashisms, based on one of the checks from the lintian system, performs basic checks on /bin/sh shell scripts for the possible presence of bashisms. It takes the names of the shell scripts on the command line, and outputs warnings if possible bashisms are detected. Note that the definition of a bashism in this context roughly equates to "a shell feature that is not required to be supported by POSIX"; this means that some issues flagged may be permitted under optional sections of POSIX, such as XSI or User Portability. In cases where POSIX and Debian Policy disagree, checkbashisms by default allows extensions permitted by Policy but may also provide options for stricter checking. OPTIONS
--help, -h Show a summary of options. --newline, -n Check for "echo -n" usage (non POSIX but required by Debian Policy 10.4.) --posix, -p Check for issues which are non POSIX but required to be supported by Debian Policy 10.4 (implies -n). --force, -f Force each script to be checked, even if it would normally not be (for instance, it has a bash or non POSIX shell shebang or appears to be a shell wrapper). --extra, -x Highlight lines which, whilst they do not contain bashisms, may be useful in determining whether a particular issue is a false posi- tive which may be ignored. For example, the use of "$BASH_ENV" may be preceded by checking whether "$BASH" is set. --version, -v Show version and copyright information. EXIT VALUES
The exit value will be 0 if no possible bashisms or other problems were detected. Otherwise it will be the sum of the following error val- ues: 1 A possible bashism was detected. 2 A file was skipped for some reason, for example, because it was unreadable or not found. The warning message will give details. SEE ALSO
lintian(1). AUTHOR
checkbashisms was originally written as a shell script by Yann Dirson <dirson@debian.org> and rewritten in Perl with many more features by Julian Gilbey <jdg@debian.org>. DEBIAN
Debian Utilities CHECKBASHISMS(1)
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy