由买买提看人间百态

topics

全部话题 - 话题: stderr
1 2 3 下页 末页 (共3页)
t****t
发帖数: 6806
1
来自主题: Programming版 - 关于STDERR定向到文件问题
perl 吗?
try this
print STDERR "normal stderr\n";
{
local *STDERR=\*ERROR;
print STDERR "to ERROR\n";
}
print STDERR "back to normal\n";
c**t
发帖数: 2744
2
来自主题: Programming版 - 关于STDERR定向到文件问题
我想在某个routine中将STDERR定向到文件,routine结束后,取消定向。
sub func
{
open(ERROR, "> somefile");
STDERR->fdopen(\*ERROR, "w);
...
close(ERROR);
}
问题是此后STDERR都消失了,怎么让它重新回到STDERR?
c**t
发帖数: 2744
3
来自主题: Programming版 - 关于STDERR定向到文件问题
yes, actually Net::Ftp->new($ftp_server, Debug =>1);
the debug information is written to stderr, I don't have control..
c**t
发帖数: 2744
4
来自主题: Programming版 - 关于STDERR定向到文件问题
gotta, local is the key. Thanks!

yes, actually Net::Ftp->new($ftp_server, Debug =>1);
the debug information is written to stderr, I don't have control..
t****t
发帖数: 6806
5
来自主题: Programming版 - 关于STDERR定向到文件问题
oh, you don't even have to open a new handle. you probably can use
{
open (local *STDERR, "> myerror") or die;
Net::Ftp ...
}
note the parenthesis for open.
m*****e
发帖数: 4193
6
来自主题: Unix版 - How to merge stdout and stderr
I want to pipe all the output (to stdout and stderr) from a program
to another program (such as cat). How to do this?
"p1 2>&1 | p2" doesn't work
s******g
发帖数: 1
7
来自主题: Unix版 - how to see the output to stderr?
Reading a program which outputs to stderr
How to see it, is there any command to redirect
it to a file.
Thanks
p****u
发帖数: 2422
8
来自主题: Linux版 - 请教个简单命令问题
from Advanced Bash-Scripting Guide:
http://www.tldp.org/LDP/abs/html/io-redirection.html
Chapter 20. I/O Redirection
Table of Contents
20.1. Using exec
20.2. Redirecting Code Blocks
20.3. Applications
There are always three default files [1] open, stdin (the keyboard), stdout
(the screen), and stderr (error messages output to the screen). These, and a
ny other open files, can be redirected. Redirection simply means capturing o
utput from a file, command, program, script, or even code block withi... 阅读全帖
b******e
发帖数: 432
9
# For this function, I think the original one is semantically wrong.
# Based on the description, I think it always needs to print to STDERR.
# However, when the option is not STDERR, it needs to print to STDOUT as
well.
#
# Besides, I may improve it by add some the restrict to input or add more
match pattern to the option, Ex:
# 1. I may trim the $option before compare.
# 1. The input option might be 'stderr', I may modify it to .
# 2. There might no input option, or no input message.
s... 阅读全帖
b******e
发帖数: 432
10
# For this function, I think the original one is semantically wrong.
# Based on the description, I think it always needs to print to STDERR.
# However, when the option is not STDERR, it needs to print to STDOUT as
well.
#
# Besides, I may improve it by add some the restrict to input or add more
match pattern to the option, Ex:
# 1. I may trim the $option before compare.
# 1. The input option might be 'stderr', I may modify it to .
# 2. There might no input option, or no input message.
s... 阅读全帖
b******e
发帖数: 432
11
# For this function, I think the original one is semantically wrong.
# Based on the description, I think it always needs to print to
STDERR.
# However, when the option is not STDERR, it needs to print to STDOUT
as well.
#
# Besides, I may improve it by add some the restrict to input or add
more match pattern to the option, Ex:
# 1. I may trim the $option before compare.
# 1. The input option might be 'stderr', I may modify it to .
# 2. There might no input option, or no input message.
sub my_wri... 阅读全帖
b******e
发帖数: 432
12
希望有PERL经验的同学指点一下,多谢啦!
There are errors in the following code, both in logic
and in syntax. Find the errors and provide the correct
fixes.
# this function prints something to stdout, unless
# the option parameter is set to STDERR, and then it
# prints out to stderr
sub writeOut
{
my $message = shift;
my $option = shift; #optional
if( $option eq 'STDERR' )
{
print STDERR $message . "\n";
}
else
{
print $message . "\n";
}
}
# this function gets the system UUID, wit... 阅读全帖
g**********t
发帖数: 475
13
# this function prints something to stdout, unless
# the option parameter is set to STDERR, and then it
# prints out to stderr
sub writeOut
{
my $message = shift;
my $option = shift; #optional
if( $option ne 'STDERR' )
{
print $message . "\n";
}
print STDERR $message . "\n";
}
# this function gets the system UUID, with or without
# dashes depending on the option
sub getUUID
{
my $option = shift; #optional
my $uuid = "8f5de6fd-5f97-4b27-be35-861c3bbbb1f1";
if( $... 阅读全帖
b******e
发帖数: 432
14
是道测试题了,周五早上之前给出答案才有效。
希望有PERL经验的同学指点一下,多谢啦!
There are errors in the following code, both in logic
and in syntax. Find the errors and provide the correct
fixes.
# this function prints something to stdout, unless
# the option parameter is set to STDERR, and then it
# prints out to stderr
sub writeOut
{
my $message = shift;
my $option = shift; #optional
if( $option eq 'STDERR' )
{
print STDERR $message . "\n";
}
else
{
print $message . "\n";
}
}
# this function get... 阅读全帖
b******e
发帖数: 432
15
是道测试题了,周五早上之前给出答案才有效。
希望有PERL经验的同学指点一下,多谢啦!
There are errors in the following code, both in logic
and in syntax. Find the errors and provide the correct
fixes.
# this function prints something to stdout, unless
# the option parameter is set to STDERR, and then it
# prints out to stderr
sub writeOut
{
my $message = shift;
my $option = shift; #optional
if( $option eq 'STDERR' )
{
print STDERR $message . "\n";
}
else
{
print $message . "\n";
}
}
# this function get... 阅读全帖
d**********x
发帖数: 4083
16
来自主题: JobHunting版 - LinkedIn 面经
H2O那个我写了个C的。可以改吧改吧加上对各种原子的计数。
编译的时候别忘了 -lpthread !
#include
#include
#include
#include
#include
#include
sem_t availH;
sem_t availO;
sem_t usedH;
sem_t usedO;
void* H(void*) {
sem_post(&availH);
sem_wait(&usedH);
fprintf(stderr, "H consumed.\n");
pthread_detach(pthread_self());
return NULL;
}
void* O(void*) {
sem_post(&availO);
sem_wait(&usedO);
fprintf(stderr, "O consumed.\n");
pthread_detach(... 阅读全帖
d**********x
发帖数: 4083
17
来自主题: JobHunting版 - LinkedIn 面经
H2O那个我写了个C的。可以改吧改吧加上对各种原子的计数。
编译的时候别忘了 -lpthread !
#include
#include
#include
#include
#include
#include
sem_t availH;
sem_t availO;
sem_t usedH;
sem_t usedO;
void* H(void*) {
sem_post(&availH);
sem_wait(&usedH);
fprintf(stderr, "H consumed.\n");
pthread_detach(pthread_self());
return NULL;
}
void* O(void*) {
sem_post(&availO);
sem_wait(&usedO);
fprintf(stderr, "O consumed.\n");
pthread_detach(... 阅读全帖
d****n
发帖数: 1637
18
来自主题: Programming版 - In C++, how to do matrix computation?
okay,没代码没真相。
here is my shabby codes and I want to share with you all.
output and analysis will be post soon
//file name matrix_op.c
#include
#include
#include
#include
#include
#include
#define _MX_INIT(type_t, row, col) ({ int i;\
type_t ** ret;\
ret=(type_t ** )malloc( row *sizeof(type_t*));\
for(i=0;i (ret);\
})
#defin... 阅读全帖
c*********n
发帖数: 182
19
来自主题: JobHunting版 - Unix高手来看看GS的UNIX题
• How many ways can you think of to remove a file called '-r'?
unlink/rm/...?
• How might one trap a SIGKILL from within shell, or C, Perl or
Python?
Perhaps there are nothing you can do with SIGKILL without patching the init.
..
• Can a Unix process become unkillable? If so, how?
Yes. uninterruptible sleep
• How would you find the disk space consumed by a directory without
using du?
don't know. find . | ls | awk | sort | awk | ... ?! &*^(&@#(*^@#
• W... 阅读全帖
b*********n
发帖数: 1258
20
来自主题: SanFrancisco版 - 菜鸟请教个hadoop streaming job 的问题
我是hadoop 菜鸟,第一次用
我的job 就是个很简单的map job, no reducer,
mapper 也就是一些很简单的命令,会有一些输出到stderr, stdout
我的hadoop 命令output option:
"-outputformat org.apache.hadoop.mapred.lib.NullOutputFormat " .
"-output NONE " .
map 一直fail,error message 如下,不论我是否supress所有的stderr, stdout,一直
是下面相同的error message.
那位高手可不可以指点一二。谢谢
java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess
failed with code 143
at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.
java:311)
at org.apac
DK
发帖数: 194
21
his fix is correct, just change ($option eq 'STDERR')
to
($option ne 'STDERR')
it should be semantically correct....
there is no syntax error here, it runs fine. even when I do "use strict;"
s***g
发帖数: 495
22
来自主题: Hardware版 - pogoplug 装 ArchLinux 一点心得
arcNumber = architecture number?
It is set in uboot so should be used by uboot to pass to the kernel.
Use a newer uboot and kernel should make it boot on sata.
I have tried on pogo v4 and it boot from all three source: usb, mmc, and
sata.
My way is different from debian forum becase I think it is easier and
confirmed by your experience too.
Here is my uboot env for pogo v4. I shared it here for the same reason.
arcNumber=3960
baudrate=115200
bootcmd=setenv bootargs console=ttyS0,$baudrate root=L... 阅读全帖
z***h
发帖数: 405
23
应该和编码没有任何关系
your java Runtime probably couldn't find ./list
print out the stderr and stderr of the process to see what the output and
error
are.
b*********n
发帖数: 1258
24
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: babyfacenan (黑土), 信区: SanFrancisco
标 题: 菜鸟请教个hadoop streaming job 的问题
发信站: BBS 未名空间站 (Sat Feb 20 19:53:34 2010, 美东)
我是hadoop 菜鸟,第一次用
我的job 就是个很简单的map job, no reducer,
mapper 也就是一些很简单的命令,会有一些输出到stderr, stdout
我的hadoop 命令output option:
"-outputformat org.apache.hadoop.mapred.lib.NullOutputFormat " .
"-output NONE " .
map 一直fail,error message 如下,不论我是否supress所有的stderr, stdout,一直
是下面相同的error message.
那位高手可不可以指点一二。谢谢
java.lang.RuntimeException: PipeMapRed.wai
h*****0
发帖数: 4889
25
自己写一个,太简单了。
从两个流“同时”读这一行为本身是定义不良的。你的需求我估计是不管
stdout或者stderr有什么内容反正显示出来就对了,就算顺序不对也没关系。
所以你用两个线程分别从stdout和stderr里读。没数据时两个线程都阻塞着,
一旦某个有数据,立即抢占“主流”。
如果你不马上显示的话,需要开足够的buffer。
u****s
发帖数: 2186
26
一个thread里读stdout and stderr就可以
我们这的这一段code主要就是为了清Runtime.exec()的stdout/stderr buffer
h*******c
发帖数: 248
27
来自主题: Linux版 - 我的home server
是的。音乐,照片都是server转的。关于音乐:
http://huyouncic.wordpress.com/2010/02/18/ape-cue-to-flac-tracks/
http://huyouncic.wordpress.com/2010/12/06/convert-flacs-to-mp3s/
关于照片:
http://huyouncic.wordpress.com/2010/12/13/jpg-resize-and-re-orientation/
watch dog的下载部分:可能需要re-format
#!/usr/bin/perl
use POSIX qw(setsid);
$SEED="/mnt/nas/hdraid1/mldonkey/seeds";
$INCOMING="/mnt/nas/hdraid1/mldonkey/incoming";
$DESTINATION="/mnt/nas/hdraid1/share";
chdir '/' or die "cannot change to /:$!";
open STDIN,'/dev/null' or di... 阅读全帖
t****t
发帖数: 6806
28
来自主题: Programming版 - A question related to pipe
usually, all streams are block buffered, unless:
if it is stderr, it's unbuffered
if it is not stderr, and refers to a terminal, it is line buffered.
you may change the behaviour by using setbuf().
b*********n
发帖数: 1258
29
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: babyfacenan (黑土), 信区: SanFrancisco
标 题: 菜鸟请教个hadoop streaming job 的问题
发信站: BBS 未名空间站 (Sat Feb 20 19:53:34 2010, 美东)
我是hadoop 菜鸟,第一次用
我的job 就是个很简单的map job, no reducer,
mapper 也就是一些很简单的命令,会有一些输出到stderr, stdout
我的hadoop 命令output option:
"-outputformat org.apache.hadoop.mapred.lib.NullOutputFormat " .
"-output NONE " .
map 一直fail,error message 如下,不论我是否supress所有的stderr, stdout,一直
是下面相同的error message.
那位高手可不可以指点一二。谢谢
java.lang.RuntimeException: PipeMapRed.wai
t****t
发帖数: 6806
30
perror writes to stderr. stderr is non-buffered by default, but you may chan
ge it.
w*s
发帖数: 7227
31
sorry was cooking food, taking care of kids ...
thank you so much !
/*Define dependencies.*/
var express = require('express');
var multer = require('multer');
var app=express();
var done=false;
var exec = require('child_process').exec;
var cmd = 'echo ';
/*Configure the multer.*/
//var istarUpload = app.use(multer({ dest: './uploads/'}).single('myUpload')
);
var istarUpload = app.use(multer({ dest: './uploads/',
rename: function (fieldname, filename) {
return filename+Date.now();
... 阅读全帖
B****g
发帖数: 83
32
// ================================================
var spawn = require('child_process').spawn;
var async = require('async');
function spawnFunc(options, cb) {
var child = spawn(options.cmd, options.args, function);
var result = '';
child.stdout.on('data', function (data) {
// do some stuff with stdout data
result += data;
});
child.stderr.on('data', function (data) {
// do some stuff with stderr data
});
child.on('close', function (code) {
// error
if (code !==... 阅读全帖
p****s
发帖数: 3184
33

command >& error
As I know, there is no way to separate stderr and stdout in c shells.
So actually the file "error" will hold both stdout and stderr.
w**n
发帖数: 88
34
output goes to stderr, redirect stderr instead
s***g
发帖数: 4
35
redirect stderr. file no. of stderr = 2.
c****j
发帖数: 258
36
redirect stderr(2) to stdout(1), then you can use more to see the output.
exec_file 2>&1 | more
pipe(|) just redirect stdout to stdin(0), not stderr
you can also put it into a file
exec_file 2>&1>logfile

我用f90编译一个model,但是错误太多,都看不到前面的。怎么办?
redirection > 不行!
| more 也不行!
谢谢各位!!!
c*****t
发帖数: 1879
37
来自主题: Unix版 - how to redirect the output
Normally, both the stderr and stdout output goes to the screen.
If you are redirecting the output to a file or command, you can
redirect stderr by
command > output.txt 2>&1
f*****h
发帖数: 228
38
给你贴了吧,大家想用都可以
#!/usr/bin/perl -w
#############################################
#Author: Jiang Li
#email: r**********[email protected]
#Creat Time: Tue 23 Oct 2012 01:37:54 PM CDT
#Vanderbilt Center for Quantitative Sciences
#############################################
use strict;
use warnings;
=pod
=head1 SYNOPSIS
Given a genbank format file (.gb), parse its feature parts (mRNA feature to
get exon regions) to get information like transcript id, gene name, etc.,
and store the result in gtf format
=he... 阅读全帖
d****k
发帖数: 41
39
来自主题: JobHunting版 - 问一道简单DP题
我也试试,请指教,C语言风格:
int longestZigZagSequence(int[] s, int size){
if(NULL == s || size < 0){
fprintf(stderr, "Incorrect parameters in longestZigZagSequence(...)!
")
exit(1);
} else if(size < 2) {
return 0;
}
int i;
int flag = 0;
int zzCount = 0;
for(i=1; i if(s[i] == s[i-1]){
continue;
} else if(s[i] > s[i-1] && flag <= 0){
zzCount++;
flag = 1;
} else if(s[i] < s
t**n
发帖数: 272
40
来自主题: JobHunting版 - 问个bloomberg的面试题
是要你重定向stderr吧...
h****a
发帖数: 70
41
来自主题: JobHunting版 - 再问个fork的题 (转载)
【 以下文字转载自 Linux 讨论区 】
发信人: himdca (how are you doing?), 信区: Linux
标 题: 再问个fork的题
发信站: BBS 未名空间站 (Thu Jun 9 03:31:30 2011, 美东)
Given the following code:
#include
int main(void)
{
int tmp;
tmp = fork();
if(tmp == 0)
{
printf("Hello ")
sleep(1)
}
else if(tmp > 0)
{
printf("World, ")
sleep(1)
}
print "Bye bye"
}
Assuming the call to fork doesn't fail, which of the following is true (zero
o... 阅读全帖
h****a
发帖数: 70
42
来自主题: JobHunting版 - 再问个fork的题 (转载)
"c This can fail if STDERR is not redirected correctly."
应该是不对的吧?
v***a
发帖数: 365
43
来自主题: JobHunting版 - 问个算法题
第一次写 c 程序,不保证正确,请自己 debug
程序假设单词是 a to z 组成
用的 bst counting, 然后 导出来 qsort
#include
#include
struct _node;
typedef struct _node {
int cc;
char c;
struct _node * n[26];
struct _node * fa;
} node;
void addToTree(node * root, node * r, const char * p1, const char * p2) {
int t;
int i;
if (p1 == p2) {
if (r->cc == 0) root->cc++;
r->cc++;
return;
}
t = (*p1) - (int)'a';
if (r->n[t] == NULL) {
r->n[t] = (node *... 阅读全帖
s********k
发帖数: 6180
44
来自主题: JobHunting版 - Unix高手来看看GS的UNIX题
Unix Questions (shell questions apply to sh/ksh/bash)
• How many ways can you think of to remove a file called '-r'?
• How might one trap a SIGKILL from within shell, or C, Perl or
Python?
• Can a Unix process become unkillable? If so, how?
• How would you find the disk space consumed by a directory without
using du?
• What happens if /dev/zero is deleted from a running system? If
you want it back, how do you recover it?
• When using a termin... 阅读全帖
b*******7
发帖数: 907
45
来自主题: JobHunting版 - 几个C语言的题目
1. what's the output? why?
#include
#include
int main()
{
while(1)
{
fprintf(stdout,"hello-std-out");
fprintf(stderr,"hello-std-err");
sleep(1);
}
return 0;
}
2. what's the output?
#include
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", (int)a);
printf("%d\n", *(int *)&a);
return 0;
}
3. can it be built? if yes, what's the result?
file1.c:
int arr[80];
file2.c:
extern int *arr;
int main(... 阅读全帖
h****m
发帖数: 57
46
P老大的信箱已经满了几个月了,股板上俺又灌水少,只能闷着头琢磨。俺Reverse
Engineering了P老大的公式,对比了一下P老大贴的LDK的图差不太多,在这里贴出来,
如果觉得能用的上,意思一下,谢谢!
Smooth = Param("Smooth", 9, 1, 200, 1);
Var= Param("STD Err Band Periods", 18, 1, 100, 1);
function SteBand( array, periods, upper )
{
Lr = LinearReg( array, periods );
se = StdErr( array, periods );
return LR + IIf( upper, 1, -1 ) * 1 * se;
}
//You can for your convenience use it to write functions that are similar to
BBandTop, BBandBot:
function SteBandTop( array, periods )
{
ret
b***k
发帖数: 2829
47
来自主题: EB23版 - 贡献一个扫号的SCRIPT
在SCRIPT的版本里:
第32行后面加:
foreach my $k (keys %{$res}) {
print STDERR "$k: $res->{$k}; \n";
}
看看输出是什么.
BTW,
多谢包子.
l*****8
发帖数: 16949
48
下面这个hello world的20天能学会吗?
[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
{
// bring in the master library
importlib("actimp.tlb");
importlib("actexp.tlb");
// bring in my interfaces
#include "pshlo.idl"
[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};
[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{
// some code related header files
importheader();
importheader();
importheader(阅读全帖
d**********o
发帖数: 1321
49
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3b c-.y file
上面这一楼贴了载止hw3b deadline时我match的结果(也就是老师可以以这些不match
的ERROR为借口不给后来我补上的成绩),但是因为当时我还是没有写完,后来感恩节
期间就接着又写了一些,而且hw5是based on hw3 & hw3b的基础上(当我hw5是based
on更好的hw3的结果时,我应该可以得更多的分吧)。
hw4因为写得比较顺利,就不曾保留任何交上去作业的output,没有什么一目了然的结
果是我可以贴在这里的。原本我是想要把自己最的一次作业hw5贴出来的,但那已经是
一个完整的compiler,而且以后我还需要用自己的course project来找工作,所以一定
就不贴最终结果了。那就贴一个hw3b的c-.y文件吧,它集中的hw1、hw2、hw3、 hw3b的
结果,是我自己hw3b *.y文件的最完整版本。这些作业里面也有很多机关一一人为增加
的难度,比如那六七个IO相关的function,不仅traverse tree、build syntax tree的
时候会成为一个考点(把它们作为一个node连在syntax... 阅读全帖
d**********o
发帖数: 1321
50
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3b c-.y file
上面这一楼贴了载止hw3b deadline时我match的结果(也就是老师可以以这些不match
的ERROR为借口不给后来我补上的成绩),但是因为当时我还是没有写完,后来感恩节
期间就接着又写了一些,而且hw5是based on hw3 & hw3b的基础上(当我hw5是based
on更好的hw3的结果时,我应该可以得更多的分吧)。
hw4因为写得比较顺利,就不曾保留任何交上去作业的output,没有什么一目了然的结
果是我可以贴在这里的。原本我是想要把自己最的一次作业hw5贴出来的,但那已经是
一个完整的compiler,而且以后我还需要用自己的course project来找工作,所以一定
就不贴最终结果了。那就贴一个hw3b的c-.y文件吧,它集中的hw1、hw2、hw3、 hw3b的
结果,是我自己hw3b *.y文件的最完整版本。这些作业里面也有很多机关一一人为增加
的难度,比如那六七个IO相关的function,不仅traverse tree、build syntax tree的
时候会成为一个考点(把它们作为一个node连在syntax... 阅读全帖
1 2 3 下页 末页 (共3页)