Page 1 of 1

how to read string from stdin and write to stdout?

Posted: Sun Feb 27, 2011 8:19 pm
by sartic
I tried width console input and printn but it is not working.

Re: how to read string from stdin and write to stdout?

Posted: Sun Feb 27, 2011 8:32 pm
by ts-soft

Re: how to read string from stdin and write to stdout?

Posted: Sun Feb 27, 2011 9:16 pm
by sartic
I read it but do not understand. I have to run program A and connect to it in connect, read & write mode?
What I want is:
program A spawns my program (B)
program A sends string to stdin of B
program B reads string from stdin
after each string program B sends string to stdout
program A receive data and send new string....

ps: i wrote squid url rewriter. A is squid (own by root) and B is my program.

Re: how to read string from stdin and write to stdout?

Posted: Mon Feb 28, 2011 9:38 am
by sartic
I wrote small test program in win and nt port of squid. Input() is reading string from stdin but I can not figure what is (or do not know how to writeprogramstringn() ) writing to stdout.

Re: how to read string from stdin and write to stdout?

Posted: Mon Feb 28, 2011 10:15 am
by Fred
You can use ReadProgramString() and WriteProgramString() if your program launch the subprocess. Then your child program can use PrintN() and Input()

Re: how to read string from stdin and write to stdout?

Posted: Mon Feb 28, 2011 1:17 pm
by sartic
Thx 4 try but my program (B) is called by another (A).
From my testing in Windows for now... printN() is writing to stdout.
I change code a little bit and it works on Windows.
I will recompile in ubuntu 32bit later. Maybe problem is ownership (program A is own by root).

Re: how to read string from stdin and write to stdout?

Posted: Tue Mar 08, 2011 6:04 pm
by sartic
Solved! I enabled threadsafe compiler option.

Re: how to read string from stdin and write to stdout?

Posted: Tue Mar 22, 2011 10:57 pm
by Joakim Christiansen
Fred wrote:You can use ReadProgramString() and WriteProgramString() if your program launch the subprocess. Then your child program can use PrintN() and Input()
What's annoying about this is that you have to open a console window first! (at least on Windows)
It would be a good idea to be able to write to stdout without the program opening a console window first.
EDIT: Okay, I spoke too soon... #PB_Program_Hide solves my problem! :D