1. system() function
- Posted by Brian Broker <bkb at CNW.COM> Dec 17, 1999
- 527 views
- Last edited Dec 18, 1999
I know this has been brought up before but couldn't find a solution. I'd like to capture output of a DOS program without sending the output to a file. Is there a way to do this? (a library with a system() function that captures the output and lets you assign it to a sequence variable) Are there plans on adding this functionality to the next release of Euphoria? Thanks, Brian
2. Re: system() function
- Posted by Robert Craig <rds at ATTCANADA.NET> Dec 17, 1999
- 494 views
- Last edited Dec 18, 1999
Brian Broker writes: > I know this has been brought up before but couldn't find > a solution. I'd like to capture output of a DOS program > without sending the output to a file. > Is there a way to do this? (a library with a system() function > that captures the output and lets you assign it to a > sequence variable) > Are there plans on adding this functionality to the next > release of Euphoria? As you are probably aware, you can already say things like: system("myprog > myoutput", 2) to get the output of "myprog" into a file called "myoutput". I guess what you want is to get the output back as a sequence of characters, or sequence of lines of characters, without ever creating a temporary file. I don't know of anything special that I can do in the interpreter to capture the output without creating a file. I don't plan to add a library routine for this, but here's something I just wrote. It uses a temporary file. I tested it lightly. function command_output(sequence command) -- return the output of a command -- as a sequence of characters integer fn, c sequence result system(command & " > cmdtemp.dat", 2) result = "" fn = open("cmdtemp.dat", "r") if fn = -1 then return result end if while 1 do c = getc(fn) if c = -1 then exit end if result = append(result, c) end while close(fn) system("del cmdtemp.dat", 2) return result end function -- TEST sequence r r = command_output("dir *.ex") puts(1, r) Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: system() function
- Posted by Kat <KSMiTH at PELL.NET> Dec 18, 1999
- 556 views
----- Original Message ----- From: Brian Broker <bkb at CNW.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Friday, December 17, 1999 8:52 PM Subject: system() function > I know this has been brought up before but couldn't find a solution. I'd > like to capture output of a DOS program without sending the output to a > file. > > Is there a way to do this? (a library with a system() function that > captures the output and lets you assign it to a sequence variable) DR-DOS does this between running programs, like windoze handles msgs between apps. Linux prolly does it better. In MS-dos, you can use the CommandTail in the running program's PSP to store under 128 bytes,, but it's destroyed when the program terminates. You could tie up a block of memory with EMS calls, store as much data as you have XMS RAM for, and access it from any running program or tsr. If you want the simple way tho, use an xms ramdrive of the smallest size you need, and store your temp data there,, ram drives are 1000x faster than a harddrive, not counting write cacheing by the hd or hd controller itself. If you are into fancy coding that most people hate, stuff the new data (under a few bytes) into the keybd buffer, if you launch the new app as a dos shelled app, the new app can use the buffer as keybd input. You could also launch a TSR, never call it, and use it's reserved code area as data storage for real programs. Note that most of these tricks work only in real mode, `cause you may not have the access to the memory locations in 32bit mode,, so your mileage may vary. I'd go with the xms ram drive myself, if you plan on staying with dos or windoze, cause it's generally fast enough, has tons of memory,, and it's 2am at the moment, and i can't think of more to say. Kat, zzzzzzzzzzz
4. Re: system() function
- Posted by Brian Broker <bkb at CNW.COM> Dec 18, 1999
- 480 views
Thank you Robert and Kat for your suggestions but perhaps I should be more specific. I would like to write a Windows GUI for a DOS command-line program. Writing to, and reading from a file seems rather inefficient in this case. Is there an easy way to redirect the output from the console to my GUI without going via disk or user intervention (like manually copying from the console window)? Perhaps by directing the output to the clipboard where I can easily grab it or maybe even more direct by just copying info from the console? Has anybody done something like this before? Thanks, Brian
5. Re: system() function
- Posted by Kat <KSMiTH at PELL.NET> Dec 18, 1999
- 481 views
----- Original Message ----- From: Brian Broker <bkb at CNW.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Saturday, December 18, 1999 4:14 AM Subject: Re: system() function > Thank you Robert and Kat for your suggestions but perhaps I should be more > specific. I would like to write a Windows GUI for a DOS command-line > program. Writing to, and reading from a file seems rather inefficient in > this case. Is there an easy way to redirect the output from the console to > my GUI without going via disk or user intervention (like manually copying > from the console window)? Perhaps by directing the output to the clipboard > where I can easily grab it or maybe even more direct by just copying info > from the console? > > Has anybody done something like this before? Oh, yeas,, your windoze Eu code can have a Win95 gui window open using win32lib calls, and a dos window open using Eu's dos commands like print() or puts(), i was doing this last nite. The windoze window gave me connection status while the dos window printed other things for debugging. I was too lazy to use the win32lib call when puts() did the job i needed. Kat
6. Re: system() function
- Posted by Bernie Ryan <bwryan at PCOM.NET> Dec 18, 1999
- 470 views
On Sat, 18 Dec 1999 05:14:16 -0500, Brian Broker <bkb at CNW.COM> wrote: >from the console window)? Perhaps by directing the output to the clipboard >where I can easily grab it or maybe even more direct by just copying info >from the console? > >Has anybody done something like this before? >Thanks, >Brian Brian : Take a look at Carl white's editor. It uses code to write and read to the windows clipboard from dos Bernie