www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - redirect stdout stdio writeln

reply GG <none none.com> writes:
Hi !
someone could say me if it's possible to redirect stdout of a program running
in background to a file.
I use writeln() to debug, I would like to redirect results of writeln() into
file. I tried :
program >> /tmp/log 2>&1
program >> /tmp/log
program &> /tmp/log
...never success.

so maybe it's not possible with writeln or I'm missing something.

Thanks !
May 11 2011
parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
GG Wrote:

 Hi !
 someone could say me if it's possible to redirect stdout of a program running
 in background to a file.
 I use writeln() to debug, I would like to redirect results of writeln() into
 file. I tried :
 program >> /tmp/log 2>&1
 program >> /tmp/log
 program &> /tmp/log
 ...never success.
 
 so maybe it's not possible with writeln or I'm missing something.
 
 Thanks !

That should work I usually just use > but no reason append shouldn't work. In fact that method of redirection is purely on your shell to handle.
May 11 2011
parent GG <none none.com> writes:
Ok I found it, I have to put stdout.writeln not writeln. But don't know why we
have to force like this. More strange, I only changed the first writeln to
stdout.writeln and all next writeln will print in file too !!! If someone know
why, I would like to understand.

Thanks.
May 12 2011