M
Ming
Hi there,
I was wondering if there was a way for popen to "hit the return key"
and continue along the same pipe. For instance in the code below, how
do I get popen to do "cd.." and then "dir/w"? I'm actually trying to
write code to run armsd - basically what happens is when you type
armsd at the c prompt, an "armsd prompt" appears, and then you type
"go" at that prompt to run armsd.
The problem here is that "go" doesn't work from the C prompt.
#include <stdio.h>
#include <string.h>
int main( )
{
FILE* handle; // handle to one end of pipe
char message[256]; // buffer for text passed through pipe
int status; // function return value
// Question: How do I get a "cd.." (or whatever) before "dir/w"?
// open a pipe to receive text from a process running "DIR"
handle = _popen("dir/w", "rt");
// read and display input received from the child process
while (fgets(message, sizeof(message), handle))
{
fprintf(stdout, message);
}
status = _pclose(handle);
return(0);
}
Any help I can get on this will be very much appreciated.
Thanks in advance,
Ming
I was wondering if there was a way for popen to "hit the return key"
and continue along the same pipe. For instance in the code below, how
do I get popen to do "cd.." and then "dir/w"? I'm actually trying to
write code to run armsd - basically what happens is when you type
armsd at the c prompt, an "armsd prompt" appears, and then you type
"go" at that prompt to run armsd.
The problem here is that "go" doesn't work from the C prompt.
#include <stdio.h>
#include <string.h>
int main( )
{
FILE* handle; // handle to one end of pipe
char message[256]; // buffer for text passed through pipe
int status; // function return value
// Question: How do I get a "cd.." (or whatever) before "dir/w"?
// open a pipe to receive text from a process running "DIR"
handle = _popen("dir/w", "rt");
// read and display input received from the child process
while (fgets(message, sizeof(message), handle))
{
fprintf(stdout, message);
}
status = _pclose(handle);
return(0);
}
Any help I can get on this will be very much appreciated.
Thanks in advance,
Ming