Hi,
I have a program that sends some output to stdout and some to stderr. I
need to separate the two using the command-line so that I direct stderr
output to a file, say fileA.txt, and stdout output to a file, say
fileB.txt. I'm trying to implement a program that would then take the
two files and use them separately. By the way, I'm on Linux. Thanks!
-Andre 7 11588
On Sun, 20 Jul 2003 17:22:14 +1000, Andre wrote: Hi,
I have a program that sends some output to stdout and some to stderr. I need to separate the two using the command-line so that I direct stderr output to a file, say fileA.txt, and stdout output to a file, say fileB.txt. I'm trying to implement a program that would then take the two files and use them separately. By the way, I'm on Linux. Thanks!
-Andre
OT.
But since it's such a small question I'll answer it anyway :P
#split stderr and stdout into seperate files
../myprog 1> stdout.file 2> stderr.file
#join stderr and stdout into the same file
../myprog &> stdout_and_stderr.file
--
main(int c,char*k,char*s){c>0?main(0,"adceoX$_k6][^hn","-7\
0#05&'40$.6'+).3+1%30"),puts(""):*s?c=!c?-*s:(putchar(45),c
),putchar(main(c,k+=*s-c*-1,s+1)):(s=0);return!s?10:10+*k;}
In 'comp.lang.c', Andre <fo********@hotmail.com> wrote: Hi,
I have a program that sends some output to stdout and some to stderr. I need to separate the two using the command-line so that I direct stderr
The command line trick is system-dependent.
output to a file, say fileA.txt, and stdout output to a file, say fileB.txt. I'm trying to implement a program that would then take the two files and use them separately. By the way, I'm on Linux. Thanks!
To stay portable, use freopen() at the very beginning of main().
if (freopen("fileB.txt", "w", stdout) != NULL)
{
if (freopen("fileA.txt", "w", stderr) != NULL)
{
/* your app. */
}
}
--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
On Sun, 20 Jul 2003 17:22:14 +1000,
Andre <fo********@hotmail.com> wrote
in Msg. <3F**************@hotmail.com> I have a program that sends some output to stdout and some to stderr. I need to separate the two using the command-line so that I direct stderr output to a file, say fileA.txt, and stdout output to a file, say fileB.txt.
This problem is entirely a shell issue (on Unix), and a trivial one-liner
as such, but dependent on the shell you're using. It has nothing to do
with the C programming language -- and therefore doesn't belong in this
group, even though both the program in question and the shell are likely
written in C. The nice folks over at comp.unix.programmer will happily
help you.
--
"With me is nothing wrong! And with you?" (from r.a.m.p)
Hi Pieter,
Thank you so much :) you helped a great deal!
regards,
-Andre
Pieter Droogendijk wrote: On Sun, 20 Jul 2003 17:22:14 +1000, Andre wrote:
Hi,
I have a program that sends some output to stdout and some to stderr. I need to separate the two using the command-line so that I direct stderr output to a file, say fileA.txt, and stdout output to a file, say fileB.txt. I'm trying to implement a program that would then take the two files and use them separately. By the way, I'm on Linux. Thanks!
-Andre
OT. But since it's such a small question I'll answer it anyway :P
#split stderr and stdout into seperate files ../myprog 1> stdout.file 2> stderr.file #join stderr and stdout into the same file ../myprog &> stdout_and_stderr.file
in comp.lang.c i read: On Sun, 20 Jul 2003 17:22:14 +1000, Andre <fo********@hotmail.com> wrote in Msg. <3F**************@hotmail.com>
I have a program that sends some output to stdout and some to stderr.
This problem is entirely a shell issue (on Unix), and a trivial one-liner as such, but dependent on the shell you're using. It has nothing to do with the C programming language -- and therefore doesn't belong in this group, even though both the program in question and the shell are likely written in C. The nice folks over at comp.unix.programmer will happily help you.
actually comp.unix.shell would be better.
programmatically, one might use freopen() to associate different files to
each stream, from within the program, an issue appropriate for either
comp.lang.c or comp.unix.programmer, though outside of the initial request.
--
a signature
In <Xn***************************@130.133.1.4> Emmanuel Delahaye <em**********@noos.fr> writes: In 'comp.lang.c', Andre <fo********@hotmail.com> wrote:
Hi,
I have a program that sends some output to stdout and some to stderr. I need to separate the two using the command-line so that I direct stderr
The command line trick is system-dependent.
output to a file, say fileA.txt, and stdout output to a file, say fileB.txt. I'm trying to implement a program that would then take the two files and use them separately. By the way, I'm on Linux. Thanks!
To stay portable, use freopen() at the very beginning of main().
if (freopen("fileB.txt", "w", stdout) != NULL) { if (freopen("fileA.txt", "w", stderr) != NULL) { /* your app. */ } }
You got it *completely* wrong!
What makes you think that fileB.txt and fileA.txt are *portable* file
names? By hardcoding file names in your code, you have given up any
hope of portability and the program itself is horribly inflexible: what
if you want to redirect to other files on the next run?
The right thing is to handle these details from outside the program,
so that the program's code remains portable and the program itself is
flexible.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
In <20*************************@binky.homeunix.org> Pieter Droogendijk <gi*@binky.homeunix.org> writes: On Sun, 20 Jul 2003 17:22:14 +1000, Andre wrote: I have a program that sends some output to stdout and some to stderr. I need to separate the two using the command-line so that I direct stderr output to a file, say fileA.txt, and stdout output to a file, say fileB.txt. I'm trying to implement a program that would then take the two files and use them separately. By the way, I'm on Linux. Thanks! OT. But since it's such a small question I'll answer it anyway :P
#split stderr and stdout into seperate files ./myprog 1> stdout.file 2> stderr.file
fangorn:~ 1780> ls 1> stdout.file 2> stderr.file
Ambiguous output redirect.
#join stderr and stdout into the same file ./myprog &> stdout_and_stderr.file
fangorn:~ 1781> ls &> stdout_and_stderr.file
Invalid null command.
What am I doing wrong? ;-)
Don't attempt to answer any question, topical or not, if you don't know
the *complete* answer!
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrei D. |
last post by:
Hello Python newsgroup,
In the process of developing a big ssh wrapper for sending commands to
multiple hosts over the last few months, I (almost accidentally, considering
I'm really just an...
|
by: Tsai Li Ming |
last post by:
Dear all,
I have a problem with a redirecting stdout and stderr. I am a top level
module and has no control over the imported modules that are making
system calls such as os.system or popen2.* ....
|
by: Laszlo Zsolt Nagy |
last post by:
Hello,
I have this code:
s = smtplib.SMTP()
s.set_debuglevel(1)
s.connect(host=smtp_host)
s.set_debuglevel(0)
log("Connected, sending e-mail")
sys.stdout.flush()
|
by: Christoph Haas |
last post by:
Evening,
I'm having trouble with running a process through Python 2.4's
subprocess module. Example code:
========================================================
def run(command):
run =...
|
by: Massi |
last post by:
Hi everyone! I'm writing a python script which uses a C-written dll. I
call the functions in the dll using ctypes, but I don't know how to
catch the output of the "printf" which the C functions...
|
by: SamG |
last post by:
How could i make, from inside the program, to have the stdout and
stderr to be printed both to a file as well the terminal(as usual).
|
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
Hello,
I have a C# application in which I start another process which produces
output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++
compiler itself! I would like to...
|
by: Guillaume Dargaud |
last post by:
Hello all,
a while ago I was pointed towards freopen as a way to redirect stderr to a
log file. It works great, but apparently the app also writes a few lines to
stdout. Now I could redirect to 2...
|
by: lovecreatesbea... |
last post by:
For example, in Bourne Shell both stdout and stderr can be re-directed
to /dev/null,
$ ./a.out 2>&1 /dev/null
then is there any difference still?
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |