1. Windows Console Output
- Posted by Hayden McKay <hmck1 at ?od?.com.au> Sep 22, 2007
- 525 views
How do I capture Windows console output from euphoria. senario: * lauch the console app useing system() * capture it's console output I want to be able to redirect output to a file but I would prefer to capture the output into a sequence for preccess, then do the file i/o myself
2. Re: Windows Console Output
- Posted by jacques deschênes <desja at g?o?etrotter.net> Sep 22, 2007
- 540 views
Hi Hayden, If the console app you launch is one that you build yourself in euphoria, then the following procedure would do it. 1) in main application create a named pipe for reading. 2) launch the child app. 3) child app. open the named pipe for writing 4) child app. send all its input to the pipe. 5) child close pipe. 6) child exit. The name of the pipe can be coded in parent and child app if they are build to always work together or the child app can be designed to receive the name of the pipe from its command line arguments. This work as well with console as with gui application. The windows api for pipes is quite simple: http://msdn2.microsoft.com/en-us/library/aa365781.aspx My watch-svr/watch-client debug tool use such a system but it use a mailslot which is a oneway multi-client named pipe. Looking at it can give you some ideas: http://www.rapideuphoria.com/watch-svr.zip regards, Jacques Deschênes
3. Re: Windows Console Output
- Posted by jacques deschênes <desja at globetrotter?ne?> Sep 22, 2007
- 522 views
I just realize that you can use pipe in that context as system() only reurn when the child process as ended. But why don't you use somthing like system("console_app > temp_file",2) then the main application open and read the data in the temp_file. jacques deschênes wrote: > > > Hi Hayden, > If the console app you launch is one that you build yourself in euphoria, then > the following procedure would do it. > 1) in main application create a named pipe for reading. > 2) launch the child app. > 3) child app. open the named pipe for writing > 4) child app. send all its input to the pipe. > 5) child close pipe. > 6) child exit. > The name of the pipe can be coded in parent and child app if they are build > to always work together or the child app can be designed to receive the name > of the pipe from its command line arguments. > This work as well with console as with gui application. > > The windows api for pipes is quite simple: <a > href="http://msdn2.microsoft.com/en-us/library/aa365781.aspx">http://msdn2.microsoft.com/en-us/library/aa365781.aspx</a> > > My watch-svr/watch-client debug tool use such a system but it use a mailslot > which is a oneway multi-client named pipe. > Looking at it can give you some ideas: <a > href="http://www.rapideuphoria.com/watch-svr.zip">http://www.rapideuphoria.com/watch-svr.zip</a> > > regards, > Jacques Deschênes
4. Re: Windows Console Output
- Posted by Hayden McKay <hmck1 at dodo.com?a?> Sep 22, 2007
- 522 views
jacques deschênes wrote: > > > Hi Hayden, > If the console app you launch is one that you build yourself in euphoria, then > the following procedure would do it. < snip > no, the console app is in some other language. it's open source so maybee i could modify then recomile but it would be better for me just to capture the output and proccess it with euphoria. BTW, thanks for link to CreatePipe() stuff
5. Re: Windows Console Output
- Posted by jacques deschênes <desja at gl?bet?otter.net> Sep 22, 2007
- 504 views
As I often use console command at work, usualy I send the output of the command to a file then I use an euphoria script to extract the information from that file. example: net view > net_view.txt exwc xtract_hosts_names.exw net_view.txt hosts.txt For a long time I have been thinking about writing a library to capture console i/o but never took the time to do it. But from you question I made some search on MSDN and found a C sample code that show how to do it and decided to write capture.e the interface would look something like it. fnVal = CaptureRun(sequence command_arg,integer Option) command_arg should be a string with the command and its arguments Option should be one or more of CAPTURE_STDIN, CAPTURE_STDOUT, CAPTURE_STDERR ored togethers. fnVal would be Process Information in a sequence or -1 if CaptureRun failed Contrary to system() or system_exec() CaptureRun() will return immediately So a dialog could be engaged between the parent process and the child process. jacques d. Hayden McKay wrote: > > jacques deschênes wrote: > > > > > > Hi Hayden, > > If the console app you launch is one that you build yourself in euphoria, > > then > > the following procedure would do it. > > < snip > > > no, the console app is in some other language. it's open source so maybee i > could modify then recomile but it would be better for me just to capture the > output and proccess it with euphoria. > > BTW, thanks for link to CreatePipe() stuff
6. Re: Windows Console Output
- Posted by don cole <doncole at pa?b?ll.net> Sep 22, 2007
- 508 views
- Last edited Sep 23, 2007
jacques deschênes wrote: > > As I often use console command at work, usualy I send the output of the > command > to a file then I use an euphoria script to extract the information from that > file. > example: > net view > net_view.txt > exwc xtract_hosts_names.exw net_view.txt hosts.txt > > For a long time I have been thinking about writing a library to capture > console > i/o but never took the time to do it. > But from you question I made some search on MSDN and found a C sample code > that > show how to do it and decided to write capture.e > the interface would look something like it. > fnVal = CaptureRun(sequence command_arg,integer Option) > command_arg should be a string with the command and its arguments > Option should be one or more of CAPTURE_STDIN, CAPTURE_STDOUT, CAPTURE_STDERR > ored togethers. > fnVal would be Process Information in a sequence or -1 if CaptureRun failed > Contrary to system() or system_exec() CaptureRun() will return immediately > So a dialog could be engaged between the parent process and the child process. > > jacques d. > > > Hayden McKay wrote: > > > > jacques deschênes wrote: > > > > > > > > > Hi Hayden, > > > If the console app you launch is one that you build yourself in euphoria, > > > then > > > the following procedure would do it. > > > > < snip > > > > > no, the console app is in some other language. it's open source so maybee i > > could modify then recomile but it would be better for me just to capture the > > output and proccess it with euphoria. > > > > BTW, thanks for link to CreatePipe() stuff Hello jacques, I too am very interested in this. As I would like to convert the console window to a text file for printing purposes. If posible I would like to see the complete code in Euphoria of course. I don't know much about C. Don Cole
7. Re: Windows Console Output
- Posted by Pete Lomax <petelomax at b?uey?nder.co.uk> Sep 23, 2007
- 501 views
jacques deschênes wrote: > For a long time I have been thinking about writing a library to capture > console i/o but never took the time to do it. > But from you question I made some search on MSDN and found a C sample code > that show how to do it and decided to write capture.e There is some code in Edita which attempts to capture console output, specifically in eacons.ew and eacons.exw. As a disclaimer, it is squarely aimed at running Eu source code via exwc.exe and is less than 100% perfect. What I did find (on win98) is that I needed a separate process (eacons.exw) to be the sacrificial lamb that locks up, with eacons.ew looking after it and sending it a wakeup/die message. Feel free to steal/ignore any of that. Regards, Pete
8. Re: Windows Console Output
- Posted by jacques deschênes <desja at ?lobetrotter.net> Sep 23, 2007
- 541 views
don cole wrote: > > jacques deschênes wrote: > > > > As I often use console command at work, usualy I send the output of the > > command > > to a file then I use an euphoria script to extract the information from that > > file. > > example: > > net view > net_view.txt > > exwc xtract_hosts_names.exw net_view.txt hosts.txt > > > > For a long time I have been thinking about writing a library to capture > > console > > i/o but never took the time to do it. > > But from you question I made some search on MSDN and found a C sample code > > that > > show how to do it and decided to write capture.e > > the interface would look something like it. > > fnVal = CaptureRun(sequence command_arg,integer Option) > > command_arg should be a string with the command and its arguments > > Option should be one or more of CAPTURE_STDIN, CAPTURE_STDOUT, > > CAPTURE_STDERR > > ored togethers. > > fnVal would be Process Information in a sequence or -1 if CaptureRun failed > > Contrary to system() or system_exec() CaptureRun() will return immediately > > So a dialog could be engaged between the parent process and the child > > process. > > > > jacques d. > > > > > > Hayden McKay wrote: > > > > > > jacques deschênes wrote: > > > > > > > > > > > > Hi Hayden, > > > > If the console app you launch is one that you build yourself in > > > > euphoria, then > > > > the following procedure would do it. > > > > > > < snip > > > > > > > no, the console app is in some other language. it's open source so maybee > > > i > > > could modify then recomile but it would be better for me just to capture > > > the > > > output and proccess it with euphoria. > > > > > > BTW, thanks for link to CreatePipe() stuff > > Hello jacques, > > I too am very interested in this. As I would like to convert the console > window > to a text file for printing purposes. If posible I would like to see the > complete > code in Euphoria of course. I don't know much about C. > > > Don Cole I spent many hours today working on capture.ew its almost done. I should be able to post it to rapideuphoria.com before monday. let to be done: code cleanup and testing features: - 100% euphoria code - can capture child process stdin (main process can pipe output to its child handle 0) - can capture child process stdout (main process capture child console output sent to hamdle 1) - can capture child process stderr (main process capture child error messages sent to handle 2) - can capture any combination of 3 above. - very simple interface - capture_exec(cmd_line,option) - capture_gets(handle) - capture_puts(handle, object data) - capture_terminate() regards, Jacques Deschênes
9. Re: Windows Console Output
- Posted by "Greg Haberek" <ghaberek at gmail.com> Sep 23, 2007
- 543 views
On 9/22/07, Pete Lomax <guest at rapideuphoria.com> wrote: > > There is some code in Edita which attempts to capture console output, > specifically in eacons.ew and eacons.exw. As a disclaimer, it is squarely aimed > at running Eu source code via exwc.exe and is less than 100% perfect. > > What I did find (on win98) is that I needed a separate process (eacons.exw) to > be the sacrificial lamb that locks up, with eacons.ew looking after it and > sending it a wakeup/die message. Feel free to steal/ignore any of that. I've toiled over this code for hours on end, mashing and mushing it into an independent include file, that uses dll.e and would be compatible with any library. The problem was, I could never get it to work properly. It kept throwing machine level exceptions at me. So I just gave up. I still have the code around somewhere if anyone's interested. -Greg