|
Posted by Tim Roberts on 12/25/07 06:09
"Vince Morgan" <vinharAtHereoptusnet.com.au> wrote:
>"Daniel Klein" <danielk@featherbrain.net> wrote:
>
>> I'm trying to get popen to work on Windows.
>>
>> Here's a simplified example of what I'm trying to get working:
>>
>> I have a hw.c program as follows:
>>
>> #include <stdio.h>
>> main()
>> {
>> printf ("Hello World!\n");
>> }
>>
>> And here's the 'popentest.php' code:
>>
>I could be wrong, but "printf()" is going to want to output to a consul, and
>I can't see how you are going to capture the output via "popen()" which is
>expecting a file pointer.
You are wrong. "printf" writes to stdout. If you run it from a console,
then stdout is connected to the console, but that's certainly not the only
option. If you type:
hw > xxx.txt
then clearly "printf" is not going to the console.
popen runs the program with stdin and stdout redirected to the calling
program. The program as he describes it should work, assuming the PHP
popen is correctly implemented on Windows.
Your suggestion about fread is also off the mark. Any of the stdio
functions will work.
>You need to capture the output as a string so
>that it can be output to the server as HTML or whatever. However you cannot
>return a string from a C executable.
Not so. Perhaps you should hold off on replying until you are in more
familiar territory.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Navigation:
[Reply to this message]
|