user-0 提问: 把STDOUT_FILENO重定向到文件后，还有linux命令到屏幕，请问解决方案？

回复:
user: user-1
content: 引用 6 楼 sppeng 的回复:[quote=引用 5 楼 user-1 的回复:] [quote=引用 4 楼 sppeng 的回复:] [quote=引用 3 楼 user-1 的回复:] [quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？[/quote] 多了什么东西，没看懂你的意思[/quote] 这是我想要的shell的标准出错： Export: Release 11.2.0.4.0 - Production on Mon Nov 21 12:03:22 2016  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  ........................ .[/quote] 看你使用的程序的用法说明了，一般有个-v选项，代且verbose,有这选项输出就会很多

user: user-0
content: 引用 5 楼 user-1 的回复:[quote=引用 4 楼 sppeng 的回复:] [quote=引用 3 楼 user-1 的回复:] [quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？[/quote] 多了什么东西，没看懂你的意思[/quote] 这是我想要的shell的标准出错： Export: Release 11.2.0.4.0 - Production on Mon Nov 21 12:03:22 2016  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in ZHS16GBK character set and UTF8 NCHAR character set . exporting pre-schema procedural objects and actions . exporting foreign function library names for user SCOTT  . exporting PUBLIC type synonyms . exporting private type synonyms . exporting object type definitions for user SCOTT  About to export SCOTT's objects ... . exporting database links . exporting sequence numbers . exporting cluster definitions . about to export SCOTT's tables via Conventional Path ... . . exporting table                          BONUS          0 rows exported . . exporting table                           DEPT          4 rows exported . . exporting table                            EMP         14 rows exported . . exporting table                       SALGRADE          5 rows exported . . exporting table                             T1         26 rows exported . . exporting table                             T3         14 rows exported . exporting synonyms . exporting views . exporting stored procedures . exporting operators . exporting referential integrity constraints . exporting triggers . exporting indextypes . exporting bitmap, functional and extensible indexes . exporting posttables actions . exporting materialized views . exporting snapshot logs . exporting job queues . exporting refresh groups and children . exporting dimensions . exporting post-schema procedural objects and actions . exporting statistics Export terminated successfully without warnings.  C的标准出错： Export: Release 11.2.0.4.0 - Production on Mon Nov 21 11:35:40 2016  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 11, Oracle and/or its affiliates.  All rights reserved.  With the Partitioning, OLAP, Data Mining and Real Application Testing optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   Export done in ZHS16GBK character set and UTF8 NCHAR character setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting pre-schema procedural objects and actionscharacter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting foreign function library names for user SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting PUBLIC type synonymsrary names for user SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting private type synonymsary names for user SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting object type definitions for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   About to export SCOTT's objects ... for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting database linksjects ... for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting sequence numberscts ... for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting cluster definitions ... for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . about to export SCOTT's tables .. for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.  via Conventional Path ...s tables .. for user SCOTT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . . exporting table                          BONUS  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.            0 rows exported                     BONUS  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . . exporting table                           DEPT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.            4 rows exported                      DEPT  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . . exporting table                            EMP  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.           14 rows exported                       EMP  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . . exporting table                       SALGRADE  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.            5 rows exported                  SALGRADE  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . . exporting table                             T1  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.           26 rows exported                        T1  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.           26 rows exported                        T1  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.  . . exporting table                             T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.           14 rows exported                       T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting synonymsrted                       T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting viewsymsrted                       T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting stored procedures                  T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting operatorsocedures                  T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting referential integrity constraints  T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting triggersial integrity constraints  T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting indextypesl integrity constraints  T31  SCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting bitmap, functional and extensible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting posttables actions and extensible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting materialized views and extensible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting snapshot logsviews and extensible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting job queuesogsviews and extensible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting refresh groups and childrennsible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting dimensionsoups and childrennsible indexesCOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting post-schema procedural objects and actionsOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting statisticsa procedural objects and actionsOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.   . exporting statisticsa procedural objects and actionsOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.  Export terminated successfully without warnings. ctionsOTT cter setng optionsbit Production 11, Oracle and/or its affiliates.  All rights reserved.

user: user-1
content: 引用 4 楼 sppeng 的回复:[quote=引用 3 楼 user-1 的回复:] [quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？[/quote] 多了什么东西，没看懂你的意思

user: user-0
content: 引用 3 楼 user-1 的回复:[quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？

user: user-1
content: 引用 2 楼 sppeng 的回复:[quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下

user: user-0
content: 引用 1 楼 user-1 的回复:估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？

user: user-1
content: 估计有的命令是向STDERR_FILENO输出的

user: user-0
content: 引用 9 楼 user-1 的回复:[quote=引用 8 楼 sppeng 的回复:] [quote=引用 7 楼 user-1 的回复:] [quote=引用 6 楼 sppeng 的回复:] [quote=引用 5 楼 user-1 的回复:] [quote=引用 4 楼 sppeng 的回复:] [quote=引用 3 楼 user-1 的回复:] [quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？[/quote] 多了什么东西，没看懂你的意思[/quote] 这是我想要的shell的标准出错： Export: Release 11.2.0.4.0 - Production on Mon Nov 21 12:03:22 2016  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  ........................ .[/quote] 看你使用的程序的用法说明了，一般有个-v选项，代且verbose,有这选项输出就会很多[/quote]  我就加了一个这个dup2(STDOUT_FILENO, STDERR_FILENO); 使用execvp调用了外部命令，然后把输出结果打印到日志！！！ dup2命令再把stdout_fileno重定向到文件 就是输出的结果原来命令的结果不太一样！！ verbose这是个啥东西，怎么用？？[/quote] 输出肯定和原来一样的，你再找找原因吧。stdout和stderr还是分开好[/quote] 谢谢，已经帮了很大的忙了！！

user: user-1
content: 引用 8 楼 sppeng 的回复:[quote=引用 7 楼 user-1 的回复:] [quote=引用 6 楼 sppeng 的回复:] [quote=引用 5 楼 user-1 的回复:] [quote=引用 4 楼 sppeng 的回复:] [quote=引用 3 楼 user-1 的回复:] [quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？[/quote] 多了什么东西，没看懂你的意思[/quote] 这是我想要的shell的标准出错： Export: Release 11.2.0.4.0 - Production on Mon Nov 21 12:03:22 2016  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  ........................ .[/quote] 看你使用的程序的用法说明了，一般有个-v选项，代且verbose,有这选项输出就会很多[/quote]  我就加了一个这个dup2(STDOUT_FILENO, STDERR_FILENO); 使用execvp调用了外部命令，然后把输出结果打印到日志！！！ dup2命令再把stdout_fileno重定向到文件 就是输出的结果原来命令的结果不太一样！！ verbose这是个啥东西，怎么用？？[/quote] 输出肯定和原来一样的，你再找找原因吧。stdout和stderr还是分开好

user: user-0
content: 引用 7 楼 user-1 的回复:[quote=引用 6 楼 sppeng 的回复:] [quote=引用 5 楼 user-1 的回复:] [quote=引用 4 楼 sppeng 的回复:] [quote=引用 3 楼 user-1 的回复:] [quote=引用 2 楼 sppeng 的回复:] [quote=引用 1 楼 user-1 的回复:] 估计有的命令是向STDERR_FILENO输出的 确实是向STDERR_FILENO里面输出了，但是里面的东西有点多，很多不是我想要的，还能把STDERR_FILENO里面的东西再区分吗？[/quote] 要么修改源码，要么自己另外写个程序将STDERR的输出过滤一下[/quote] 谢谢，我在问下，我用shell重定向命令执行结果，把 2>定向到文件就是我想要的结果了，为啥C的标准出错多了东西呢！！您碰到过吗？？[/quote] 多了什么东西，没看懂你的意思[/quote] 这是我想要的shell的标准出错： Export: Release 11.2.0.4.0 - Production on Mon Nov 21 12:03:22 2016  Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.  ........................ .[/quote] 看你使用的程序的用法说明了，一般有个-v选项，代且verbose,有这选项输出就会很多[/quote]  我就加了一个这个dup2(STDOUT_FILENO, STDERR_FILENO); 使用execvp调用了外部命令，然后把输出结果打印到日志！！！ dup2命令再把stdout_fileno重定向到文件 就是输出的结果原来命令的结果不太一样！！ verbose这是个啥东西，怎么用？？