Does anyone know how to force console output into file in C++?
I need to check the results from the console output generated by other programs not done by me. (e.g. ping)
Name:
Anonymous2006-01-18 6:42
Are you spawning them with forc-exec? If so, redirect their stdout.
Name:
Anonymous2006-01-18 6:46
You're a troll. Only an idiot'd try to write a separate program to do something already provided by their console.
Either that, or you want us to do your homework for you.
>>4 >>5
Hi, thanks for replying.
Perhaps I should have been more clear.
See, I need to check if the command was in fact
valid in the first place.
I am trying to automate a module test.
But I need to know if certain executables
exist in the first place.
command [args] > file.txt
only pipes the program console stream to a file stream.
I want to know how to force CONSOLE output into file in C++?
In order to read the " is not recognized as ... command ..."
so that I can know wether the command was valid in first place
>>6
Oh I see. Well, you can just see if the file exists (by calling stat on it). Or, if you want $PATH interpreted and all, you can do something like fork, grab stdout and stderr for reading by the parent process (they were files number 1 and 2 IIRC), then exec "bash -c command".
However, I think you're using the worst tool for this. You seem to need a scripting language. I suggest PHP-CLI, it's simple, has a nice syntax, and it's great for system scripting. What you want to do is much easier done on scripting languages; C++ is not really meant to do this.
Name:
Anonymous2006-01-19 7:52
termio can be manipulated from within a program and file descriptors set through the terminal
getopts + decent code structure helps
Name:
Anonymous2006-01-19 20:37
"not recognized" comes from the shell. The C++ version would be the system call that executes the command returning an error code, etc..
Name:
Anonymous2009-05-17 21:49
IF YOU'RE READING THIS THEN YOU NOW KNOW THAT MICKEY ROURKE HAS AN EXTREME DISTRUST IN THE METHODS TAUGHT BY SICP.
your gay what about my gay?
enola gay
who are you quoting?
it's still shitposting even if you are being ironic
96% of all kids these days listen to shitty music like dubstep
upvote this post if your a part of the 4% who still like real music like linkin park