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 11645
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_stde rr.file
--
main(int c,char*k,char*s ){c>0?main(0,"a dceoX$_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);r eturn!s?10:10+* k;}
In 'comp.lang.c', Andre <fo********@hot mail.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**********@no os.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********@hot mail.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.progr ammer 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_stde rr.file
in comp.lang.c i read: On Sun, 20 Jul 2003 17:22:14 +1000, Andre <fo********@hot mail.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.progr ammer will happily help you.
actually comp.unix.shell would be better.
programmaticall y, 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.progr ammer, though outside of the initial request.
--
a signature
In <Xn************ *************** @130.133.1.4> Emmanuel Delahaye <em**********@n oos.fr> writes: In 'comp.lang.c', Andre <fo********@hot mail.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************ *************@b inky.homeunix.o rg> Pieter Droogendijk <gi*@binky.home unix.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_stde rr.file
fangorn:~ 1781> ls &> stdout_and_stde rr.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 "amateur hacker" :-) was very pleased to discover at one
stage how to run processes in parallel using python, which is powerful
technology to say the least, applicable not only in my project but in lots
of other areas as well.
Anyway, what I...
|
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.* . I have tried the simplest
method of capturing stdout, stderr via:
saveout = sys.stdout
sys.stdout = file_obj
|
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 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Wait for the process to return
|
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 use. In fact I
don't even know if it is possible! I've heard something about PIPE and
popen...is this what I need? How can I use them? It is very important
for me that I could take the output in real-time.
Thanks for the help!
Massi
| |
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 capture the results of the compile and
display them in a RichTextBox. The problem I'm having is that when I
intentionally introduce an error in the C code I'm compiling, I can't read
the error output in my C# program. I've tried redirecting both...
|
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 separate files, but would rather keep the
2 flows together.
Is it correct to do this:
stderr=freopen(LogFile, "w", stderr);
stdout=freopen(LogFile, "a", stdout);
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |