由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
_Xiyu版 - 硬工碰到软问题
相关主题
xiyu open 2009_lovecountry (4)西羽poster - 最终稿
诚征女搭挡. (XIYU OPEN)9/30 sortie队出场名单
我的xiyu open 2010--前言XYT ZYMF vs Sortie 9/30 报告
xiyu close昨天xyt汇报(2)
快乐的周末 --- xiyu open 杂记 (1)昨天xyt汇报(完)
快乐的周末 --- xiyu open 杂记 (2)11/04比赛日记(5)
快乐的周末 --- xiyu open 杂记 (3)第一次混双比赛(3)
快乐的周末 --- xiyu open 杂记 (4)昨晚ubc
相关话题的讨论汇总
话题: log话题: stdout话题: print话题: file话题: logfile
1 (共1页)
i*****8
发帖数: 6735
1
熟悉perl的大侠们,
我需要deliver个perl program,user run这个程序的时候有个-logfile option。
可是我想把要print到logfile里的东西在stdout上也显示出来。
simple的方法就是每个msg print两次。
有没有办法只用一次print command,两个地方都有msg了呢?
i*****8
发帖数: 6735
2
我在网上找了找 output redirect, 不大明白啊

【在 i*****8 的大作中提到】
: 熟悉perl的大侠们,
: 我需要deliver个perl program,user run这个程序的时候有个-logfile option。
: 可是我想把要print到logfile里的东西在stdout上也显示出来。
: simple的方法就是每个msg print两次。
: 有没有办法只用一次print command,两个地方都有msg了呢?

c**e
发帖数: 457
3
Try this. It will print to stdout and your-log-file
===========================
#!/usr/bin/perl
open (STDOUT, "| tee -a your-log-file");
print "We love Xiyu!";
close (STDOUT);
===========================

【在 i*****8 的大作中提到】
: 熟悉perl的大侠们,
: 我需要deliver个perl program,user run这个程序的时候有个-logfile option。
: 可是我想把要print到logfile里的东西在stdout上也显示出来。
: simple的方法就是每个msg print两次。
: 有没有办法只用一次print command,两个地方都有msg了呢?

t*h
发帖数: 1629
4
他要反过来,估计事。
现有的程序已经全部print到一个logfile,现在要重新输出出来。要看看
那个logfi
le怎么打开的德,是不是这么把stdout 重订向导file的

【在 c**e 的大作中提到】
: Try this. It will print to stdout and your-log-file
: ===========================
: #!/usr/bin/perl
: open (STDOUT, "| tee -a your-log-file");
: print "We love Xiyu!";
: close (STDOUT);
: ===========================

g******d
发帖数: 1774
5
又读了一下 requirement, 好像cade是对的。

【在 t*h 的大作中提到】
: 他要反过来,估计事。
: 现有的程序已经全部print到一个logfile,现在要重新输出出来。要看看
: 那个logfi
: le怎么打开的德,是不是这么把stdout 重订向导file的

c**e
发帖数: 457
6
为什么有正反先后问题呢,这个程序同时写到stdout和log file啊?

【在 t*h 的大作中提到】
: 他要反过来,估计事。
: 现有的程序已经全部print到一个logfile,现在要重新输出出来。要看看
: 那个logfi
: le怎么打开的德,是不是这么把stdout 重订向导file的

i*****8
发帖数: 6735
7
待我一个个try来。多些诸位答复!

【在 c**e 的大作中提到】
: 为什么有正反先后问题呢,这个程序同时写到stdout和log file啊?
d*****d
发帖数: 2449
8
like tch said, cade's solution is another way around, instead of copying the
log from the log file to the stdout, it copies stdout to the file. If you
can direct the log to stdout it will work, otherwise it won't.
If you don't need to see the log in the same console, just use "tail -f $LOG
" while $LOG is the name of the log file then you'll see the log output on
the fly.
d*****d
发帖数: 2449
9
又看了一下问题,原来是你要写这个程序,那就无所谓了。
c**e
发帖数: 457
10
Instead of print the log to the log file handler, just print the log to
stdout in the existing perl program. It should be a very simple change.
For examle,
Change
print LOG-FILE "We love xiyu"
to
print "We love xiyu" to
I do not see whey you can not do that.

the
LOG

【在 d*****d 的大作中提到】
: like tch said, cade's solution is another way around, instead of copying the
: log from the log file to the stdout, it copies stdout to the file. If you
: can direct the log to stdout it will work, otherwise it won't.
: If you don't need to see the log in the same console, just use "tail -f $LOG
: " while $LOG is the name of the log file then you'll see the log output on
: the fly.

相关主题
快乐的周末 --- xiyu open 杂记 (2)西羽poster - 最终稿
快乐的周末 --- xiyu open 杂记 (3)9/30 sortie队出场名单
快乐的周末 --- xiyu open 杂记 (4)XYT ZYMF vs Sortie 9/30 报告
d*****d
发帖数: 2449
11

对不起,我错了,我又犯了审题不清的老毛病,我检讨。我以为v8要run一个现成的
perl程序。

【在 c**e 的大作中提到】
: Instead of print the log to the log file handler, just print the log to
: stdout in the existing perl program. It should be a very simple change.
: For examle,
: Change
: print LOG-FILE "We love xiyu"
: to
: print "We love xiyu" to
: I do not see whey you can not do that.
:
: the

c**e
发帖数: 457
12
I see ur point :)

【在 d*****d 的大作中提到】
:
: 对不起,我错了,我又犯了审题不清的老毛病,我检讨。我以为v8要run一个现成的
: perl程序。

u****u
发帖数: 2308
13
IMHO 你的这个要求是unix programming所忌讳的。dumbird建议的tail -f $logfile才
是王道。

【在 i*****8 的大作中提到】
: 熟悉perl的大侠们,
: 我需要deliver个perl program,user run这个程序的时候有个-logfile option。
: 可是我想把要print到logfile里的东西在stdout上也显示出来。
: simple的方法就是每个msg print两次。
: 有没有办法只用一次print command,两个地方都有msg了呢?

i*****8
发帖数: 6735
14
有啥忌讳?cade的方法好像可行啊。这个tail -f是要user自己干的,是extra的work。
很多时候重要的信息不print到stout上他们不知道要去看log啊

【在 u****u 的大作中提到】
: IMHO 你的这个要求是unix programming所忌讳的。dumbird建议的tail -f $logfile才
: 是王道。

t*h
发帖数: 1629
15
最简单的就是去掉那个logfile option.如果他们要save 下来,就用重定向。
用 > xxx.log
or | tee xxx.log
前者没有screen output
后者有

【在 i*****8 的大作中提到】
: 有啥忌讳?cade的方法好像可行啊。这个tail -f是要user自己干的,是extra的work。
: 很多时候重要的信息不print到stout上他们不知道要去看log啊

i*****8
发帖数: 6735
16
去掉logfile option万一出了问题我就无据可查了。。。我还想着偷偷加个logfile,
colect些statistics自己用,嘿嘿

【在 t*h 的大作中提到】
: 最简单的就是去掉那个logfile option.如果他们要save 下来,就用重定向。
: 用 > xxx.log
: or | tee xxx.log
: 前者没有screen output
: 后者有

u****u
发帖数: 2308
17
你这个user一会儿是自己一会儿是别人,到底给谁用的啊?

【在 i*****8 的大作中提到】
: 去掉logfile option万一出了问题我就无据可查了。。。我还想着偷偷加个logfile,
: colect些statistics自己用,嘿嘿

i*****8
发帖数: 6735
18
user说的是别人啊,所以要把最坏的可能性都想到。我收集的statistics无非是什么人
什么时间用了这个script之类的

【在 u****u 的大作中提到】
: 你这个user一会儿是自己一会儿是别人,到底给谁用的啊?
u****u
发帖数: 2308
19
你是想要纪录谁在什么时间运行了某个程序?

【在 i*****8 的大作中提到】
: user说的是别人啊,所以要把最坏的可能性都想到。我收集的statistics无非是什么人
: 什么时间用了这个script之类的

i*****8
发帖数: 6735
20
我是这个程序的owner。我就想知道有多少user在什么时间用了我这个程序,方便以后
show给LD看

【在 u****u 的大作中提到】
: 你是想要纪录谁在什么时间运行了某个程序?
1 (共1页)
相关主题
昨晚ubc快乐的周末 --- xiyu open 杂记 (1)
GGBC member 最新进展。快乐的周末 --- xiyu open 杂记 (2)
ok, final deal update快乐的周末 --- xiyu open 杂记 (3)
牛裸奔快乐的周末 --- xiyu open 杂记 (4)
xiyu open 2009_lovecountry (4)西羽poster - 最终稿
诚征女搭挡. (XIYU OPEN)9/30 sortie队出场名单
我的xiyu open 2010--前言XYT ZYMF vs Sortie 9/30 报告
xiyu close昨天xyt汇报(2)
相关话题的讨论汇总
话题: log话题: stdout话题: print话题: file话题: logfile