LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: enruan

如何将标准错误输出重定向到一个文件的同时在屏幕上也显示,谢谢[基本解决]

 关闭 [复制链接]
 楼主| 发表于 2004-4-12 14:14:32 | 显示全部楼层

And that one


  1. root # [color=green](make;date;sleep 5;make;date) 2>&1 >2 | tee logfile[/color]
  2. -bash: make: command not found
  3. 五秒钟后
  4. -bash: make: command not found
  5. root # [color=green]more logfile[/color]
  6. -bash: make: command not found
  7. -bash: make: command not found
  8. root # [color=green](make;date;sleep 5;make;date) >2 2>&1 | tee logfile[/color]
  9. 五秒钟后
  10. root # [color=green]more logfile[/color]
  11. root #
复制代码

为什么会这样



怎么会变成都是空的了
 楼主| 发表于 2004-4-12 14:30:12 | 显示全部楼层
最初由 enruan 发表
是不是说这样也行啊?

  1. exec 9>&1
  2. cmd 2>&1 >&9 | tee logfile
  3. exec 9>&-
复制代码


这个是不是更好一点儿


  1. (make;date;sleep 5;make;date) 2>&1 >/dev/tty | tee logfile
复制代码
 楼主| 发表于 2004-4-12 14:40:10 | 显示全部楼层

晕,怎么成[已解决]了,还有没明白的东东啊

.
发表于 2004-4-12 17:23:46 | 显示全部楼层

回复: Faint,why

最初由 enruan 发表

  1. root # [color=green](make;date;sleep 5;make;date) 2>logfile | cat logfile[/color]
  2. -bash: make: command not found
  3. root # [color=green]more logfile[/color]
  4. -bash: make: command not found
  5. -bash: make: command not found
复制代码

你安装了make嘛?

  1. whereis make
复制代码
发表于 2004-4-12 17:24:29 | 显示全部楼层

回复: And that one

最初由 enruan 发表

  1. root # [color=green](make;date;sleep 5;make;date) 2>&1 >2 | tee logfile[/color]
  2. -bash: make: command not found
  3. 五秒钟后
  4. -bash: make: command not found
  5. root # [color=green]more logfile[/color]
  6. -bash: make: command not found
  7. -bash: make: command not found
  8. root # [color=green](make;date;sleep 5;make;date) >2 2>&1 | tee logfile[/color]
  9. 五秒钟后
  10. root # [color=green]more logfile[/color]
  11. root #
复制代码

为什么会这样

很明显,是同一个错误,系统找不到make命令。whereis make
发表于 2004-4-12 17:25:43 | 显示全部楼层
最初由 enruan 发表
这个是不是更好一点儿


  1. (make;date;sleep 5;make;date) 2>&1 >/dev/tty | tee logfile
复制代码

你是要看输出,为什么要把输出放到/dev/tty呢?这样不是很矛盾嘛?
发表于 2004-4-12 17:28:07 | 显示全部楼层

回复: 晕,怎么成[已解决]了,还有没明白的东东啊

最初由 enruan 发表
.

sorry,在下今天下午要上课。
希望以后兄弟要耐心点,另外,要把问题说明白。
我是根据你的回复,而且你要求的功能的确已经实现了呀。才把帖子置成已解决的。如果有不对的地方,还请你多多包涵。我现在把它置回原状,ok。
发表于 2004-4-12 17:33:27 | 显示全部楼层
(make;date;sleep 5;make;date) 2>&1 >/dev/tty | tee logfile

try it:


  1. (make;date;sleep 5;make;date) 2>&1|tee logfile
复制代码
 楼主| 发表于 2004-4-12 18:16:26 | 显示全部楼层
最初由 javalee 发表
try it:


  1. (make;date;sleep 5;make;date) 2>&1|tee logfile
复制代码


这样不行,logfile 里只要2的,不要1的
 楼主| 发表于 2004-4-12 18:20:03 | 显示全部楼层

回复: 回复: Faint,why

最初由 home_king 发表
你安装了make嘛?

  1. whereis make
复制代码


sorry

没说清

make 是专门产生错误的

请教主仔细看看,我问的不是这个

见下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表