[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: Redirecting Windows command ouput to vDosXy [LONG!]




Wow, that's very impressive! It seems that I, for one, will be able to
put those tools to very good use (given the way in which I use XyWrite).
 Great video, too! (What software do you use to create the videos?)


Martin

On 29/11/2014 8:09 PM, Carl Distefano wrote:
Preamble: To skip over the technical detail and just see what I've been up to, click on the video link at the bottom of this post. As you may know from my recent posts and videos about running XyWrite in various virtual machines, my ongoing quest has been to integrate XyWrite, particularly XyWrite 4, as closely as possible with the host 64-bit Windows operating system. I've demo'd a way (which I've yet to document, but will) -- using a folder shared by the host OS and the VM -- to launch and switch to Windows programs and to issue DOS commands to the host OS. I've also developed (but not yet shown) a way to redirect command or program output back to XyWrite. ("Output", of course, means plain-text output.) This method, which I've dubbed "Xyagra", depends on having a BATch file running continuously (and harmlessly) on the host Windows system. Xyagra works well for XyWrite 4 in Oracle VirtualBox (running either 32-bit Win 7 or W2K), and I've recently shown to my own satisfaction (but not shared here) that it also works in vDosXy. That said, I've also documented on the list that vDosXy has internal hooks that allow Windows commands and programs to be launched directly from the XyWrite command line: http://www.freelists.org/post/xywrite/vDosXy-on-second-display,2 So it seemed to me that vDosXy, sans Xyagra, should be potent enough on its own to redirect 64-bit command and program output -- including Long Filename output, such as DIR listings -- back to XyWrite. I've been experimenting with various possibilities -- and experiencing a lot of frustration along the way. The penny finally dropped, but the solution was not exactly obvious. Here's a (much-compressed) summary of my trial- and-error journey to the desired result: 1. DOS At the vDos command prompt I tried various comands with varying results, including: Command : DIR C:\ > C:\DIR.OUT Result : 8.3 DIR listing in C:\DIR.OUT Command : CMD.EXE /C DIR C:\ > C:\DIR.OUT Result : Empty C:\DIR.OUT Command : CMD.EXE /C "DIR C:\ > C:\DIR.OUT" Result : Long DIR listing C:\DIR.OUT The last result was encouraging. Naively, I expected that if I issued the same command from the XyWrite CMline, LFN output should be directed to DIR.OUT and it should be possible to get that output into XyWrite by CAlling DIR.OUT. So... 2. XyWrite 4 In Xy4 I tried many commands similar to the above, often with surprising -- and disappointing -- results, including the following: Command : DOS/NV/Z /C DIR C:\ > C:\DIR.OUT Result : 8.3 DIR listing in C:\DIR.OUT with Ascii-10 newlines(??) Command : DOS/NV/Z /C CMD.EXE /C DIR C:\ > C:\DIR.OUT Result : Empty C:\DIR.OUT And this -- which worked in DOS: Command : DOS/NV/Z /C "DIR C:\ > C:\DIR.OUT" Result : 8.3 DIR listing in C:\DIR.OUT with Ascii-10 newlines Also this: Command1: DOS/NV/Z /C CMD.EXE /C START DIR C:\ > C:\DIR.OUT Command2: DOS/NV/Z /C CMD.EXE /C START "DIR C:\ > C:\DIR.OUT" Result : Empty C:\DIR.OUT (DIR listing scrolls in external window) In short, no dice. The command that directed the LFN dir listing to a file at the DOS prompt produced only an 8.3 DIR listing or an empty file when launched from XyWrite. Then a light bulb went on, and I tried burying the command in a BATch file: Command : DOS/NV/Z /C CMD.EXE /C CDIR.BAT, where CDIR.BAT contains: rem start @echo off cmd.exe /c "DIR C:\ > C:\DIR.OUT" exit rem end Result : Long DIR listing in C:\DIR.OUT, editable in XyWrite At last, success! It's not clear to me why the BATch file works where the bare command doesn't, but there you have it. Generalizing from the last example: Command : DOS/NV/Z /C CMD.EXE /C MYCMD.BAT [Win_command] [args] where MYCMD.BAT contains: rem start @echo off cmd.exe /c "%1 %2 %3 %4 %5 %6 %7 %8 %9 > C:\OUTPUT.TXT" exit rem end Result : Output of [command] [args] in C:\OUTPUT.TXT Example A: DOS/NV/Z /C CMD.EXE /C MYCMD.BAT dir/s f:\*.txt Output in C:\OUTPUT.TXT: DIR listing of all .TXT files on drive F: Example B: DOS/NV/Z /C CMD.EXE /C MYCMD.BAT tasklist.exe /? Output in C:\OUTPUT.TXT: Help screen for Windows tasklist.exe command Example C (note use of carats to "escape" double-quotes in command): DOS/NV/Z /C CMD /C MYCMD.BAT tasklist /FI ^"sessionname eq console^" Output in C:\OUTPUT.TXT: List of "Console" processes running in the host Windows system. The technique works not only with CMD.EXE commands, but also with Windows program output (though it's often necessary to insert a START command before the program name within the BATch file): Example D: DOS/NV/Z /C CMD /C MYCMD.BAT C:\Locate32\locate.exe -lf -R -t jpg Output in C:\OUTPUT.TXT: List of all .JPG files on the hard drive The implications of this technique are ... interesting. For one thing, it means that you can issue commands to the 64-bit Windows host system -- using native drive and path names and LFNs, irrespective of whether those drives and directories are shared with vDos -- and view the results in XyWrite, without ever leaving XyWrite. (The BATch file and output file must be on a shared drive, however.) For another, it means that you can CAll, edit, and SAve files in XyWrite, again using native Windows paths and long filenames. I've been working on a suite of U2 routines for Xy4 that proves the concept and, in my testing so far, works well in practice. Here's a short video, which I hope you'll enjoy: http://youtu.be/oG39SdAMHRA
-- Martin J. Osborne http://www.economics.utoronto.ca/osborne Theoretical Economics, a journal of the Econometric Society http://econtheory.org Follow TE: http://twitter.com/EconTheory