![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| can't redirect stderr in bash | lumix | Shell Programming and Scripting | 3 | 12-16-2007 01:28 AM |
| how to redirect stderr from top with csh | umen | Shell Programming and Scripting | 2 | 02-22-2007 10:19 PM |
| how can i redirect stderr to file in Make? | umen | Shell Programming and Scripting | 0 | 02-15-2007 01:04 AM |
| redirect stderr and/or stdout to /dev/null from command line | knc9233 | UNIX for Dummies Questions & Answers | 1 | 01-25-2007 09:24 AM |
| Redirect stdout and stderr | zcurtis | Shell Programming and Scripting | 8 | 09-02-2002 03:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 etc ;; \?) direct actual error message to dev/null exit 1 ;; esac done |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
Code:
while getopts "abcd" opt
do
case "$opt" in
i) a etc ;;
r) b etc ;;
f) c etc ;;
v) d etc ;;
*) exit 1 ;;
esac
done
|
|
#3
|
|||
|
|||
|
That doesn't work. It still outputs that -j is an invalid option
|
|
#4
|
|||
|
|||
|
if you are so particular about the error messages from bash...
then this would do.. Code:
bash <yourscript> 2>/dev/null |
|
#5
|
||||
|
||||
|
Playing around...
Code:
while getopts "abcd" opt
do
case "$opt" in
i) a etc ;;
r) b etc ;;
f) c etc ;;
v) d etc ;;
\?) echo "$opt" 2>/dev/null ; exit 1 ;;
esac
done
|
|
#6
|
||||
|
||||
|
Else see this link - . Handling Command Line Arguments
|
|
#7
|
|||
|
|||
|
I'm afraid neither of those two solutions work. Both still print the error message, with the added bonus of yours producing a question mark as well, Vino.
|
|||
| Google The UNIX and Linux Forums |