Save the output of command in file MS-DOS 1.x

27

4

It seems that [COMMAND]>[FILE] does not work in the early versions of MS-DOS. I am using MS-DOS 1.25 and the above expression gives the statement invalid argument.

Update:Since it is true that it does not work in DOS 1.x then is it possible to get that output using some functionality of virtual box or say by getting the output from some log files.

Blake

Posted 2016-08-24T21:58:55.563

Reputation: 380

What you're saying may well be true (I was spared contact with DOS until DOS 3). What is your question? What does the documentation say? – AFH – 2016-08-24T22:02:57.923

In the documentation there is not even a word about saving output in a separate file. In MS-DOS 2.11 it is working but I need a way in ver 1.25. – Blake – 2016-08-24T22:22:37.987

I assume then that DOS 1 preceded redirection. If the program doesn't have an option to write its output to a file then you're stuck with the limitations of DOS 1. Is there some reason why you can't run your program in a later DOS? If so, you may be able to capture output using functions provided by a VM or a DOS 1 emulator, but I have never done this, so I can't advise. – AFH – 2016-08-24T22:32:37.720

18Why are you using DOS 1.25?! – Keltari – 2016-08-24T23:24:45.093

Yes, I am using 1.25. – Blake – 2016-08-25T07:01:20.037

41@Keltari: No annoying Windows 10 update notifications – Mark K Cowan – 2016-08-25T11:31:56.357

6

If you have any other questions about your setup that wouldn't be on-topic here, try [retrocomputing.se], another SE site dedicated to that sort of thing. (Full disclosure: I may be a little bit affiliated with that site.)

– wizzwizz4 – 2016-08-25T13:08:58.080

Thank you I didn't know it exists, it is a good point you made. – Blake – 2016-08-25T13:31:22.363

4This question makes me feel young again! – Dmitry Grigoryev – 2016-08-25T14:44:16.000

9MS-DOS 1.x is essentially a CP/M clone, where Ctrl-P triggered copying the console output to the printer. A similar approach may therefore be possible in MS-DOS too. – Thorbjørn Ravn Andersen – 2016-08-25T15:09:05.687

besides the retro staciexchange site which looks interesting, You could try asking on the dostips forum – barlop – 2016-08-25T18:03:49.310

@MarkKCowan it stopped notify you to update a long time ago. And unless the OP wants to do it for fun, there's no need to use such ancient DOS nowadays – phuclv – 2016-08-26T03:05:17.113

2@LưuVĩnhPhúc I was joking :) – Mark K Cowan – 2016-08-26T07:26:14.223

2This sounds like an X/Y problem. Why are you using 1.25, and what are you actually trying to achieve? – Martin Bonner supports Monica – 2016-08-26T10:50:08.530

Keltari is asking why you're using 1.25, not "are you using 1.25" – phuclv – 2016-08-26T16:31:51.930

I don't find any reason for running such ancient 35-year-old DOS nowadays, especially when DOS already has versions 6/7/8. But it would be an interesting topic on http://retrocomputing.stackexchange.com/

– phuclv – 2016-11-26T10:34:49.627

Answers

5

you can use your virtual machine debugging facilities (or gdb/something else) to read memory directly. ms-dos has no memory protection nor it's a multi-task system, so you can read virtual machine memory, you can read virtual machine vga for input.

documentation says there exists a command

info vgatext -- print the contents of the VGA framebuffer formatted as standard text mode

the correct syntax to get output is: run VirtualBox --debug --startvm msdos1.25, then, in debugger console: info vgatext

copy-pasted output:

The COMPAQ Personal Computer DOS                                                
Version 1.11                                                                    


(C) Copyright COMPAQ Computer Corp. 1982                                        
(C) Copyright Microsoft 1981, 82                                                


A>                                                                              











--------------------------------------------------------------------------------
VBoxDbg> 

So, you can write a debugger script which hooks on a memory value inside your program's memory and dumps vga screen when a program does output / or you can write script that pauses cpu, saves content consistently, if output changes, saves updated content, continues cpu run

Some options to investigate are:

  • find how to write a debugging script for dumping memory contents of your application

  • find some debugging vga driver/serial port/memory dumping solution for quemu/dosbox/virtualbox

  • find some OLD utility program from 80's which maybe someone wrote back there for this purpose

  • add freedos tag here (or even move/repeat your question on big stackoverflow, I suppose some gurus should know a thing about problems like this

I'll update later if I find something interesting, but can you please reveal some details on why are you using 1.25, does this program works on newer versions of msdos? I bet you can find some young assembly hacker eager to patch-up this program to a newer version (or add file output with asm) for a small fee

strangeqargo

Posted 2016-08-24T21:58:55.563

Reputation: 166

Could you give some additional info about that process, please? – Blake – 2016-08-28T15:28:32.577

@Blake updated, seems info vgatext works afterall all you have to do is to write a correct script for debugger it seems – strangeqargo – 2016-08-28T21:30:24.770

The info you gave is very interesting. In fact it may be absolutely usable for my situation. I am using this for old application which I want to understand how it is working by giving it input and getting output automatically. It may be not the best way but I want to do it like this. Thank you for the answer, just give me day or two to read this manual and write some sort of script (hope it is possible) and will give you information on whether it works. Thank you a lot. – Blake – 2016-08-29T00:23:44.440

1If I haven't already marked answer, I would definitely mark this. Thank you for all of your help guys. – Blake – 2016-08-29T15:17:55.747

does scripting works? it could be cool to see an example – strangeqargo – 2016-08-29T17:07:46.363

1I needed to get output of my application as a text. In the documentation is mentioned how to use the debug console in the terminal. Using VBoxManaged debugvms <name of the already started in debug mode VM> info vgatext it prints you the screen in terminal mode and them using redirection and some sort of simple parsing I managed to get what I needed. Thank you. – Blake – 2016-08-29T17:21:15.600

This method may imply some difficulties in the future work but for now I think it is exactly what I needed. – Blake – 2016-08-29T17:26:30.163

40

It seems that [COMMAND]>[FILE] does not work in the early versions of MS-DOS.

I am using MS-DOS 1.25 and the above expression gives the statement invalid argument

That is correct. What you want to do is not possible in v1.25.

Command redirection (along with many other improvements) was added in v2.0.

MS-DOS version 2.0 (equivalent to PC-DOS 2.0) was first released in March 1983. It was, in retrospect, a new operating system (though great care was taken to maintain compatibility with MS-DOS version 1). It contained many significant innovations and enhanced features, including those listed on the following page.

  • Support for both larger-capacity floppy disks and hard disks
  • Many UNIX/XENIX-like features, including a hierarchical file structure, file handles, I/O redirection, pipes, and filters
  • Background printing (print spooling)
  • Volume labels, plus additional file attributes
  • Installable device drivers
  • A user-customizable system-configuration file that controlled the loading of additional device drivers, the number of system disk buffers, and so forth
  • Maintenance of environment blocks that could be used to pass information between programs
  • An optional ANSI display driver that allowed programs to position the cursor and control display characteristics in a hardware-independent manner
  • Support for the dynamic allocation, modification, and release of memory by application programs
  • Support for customized user command interpreters (shells)
  • System tables to assist application software in modifying its currency, time, and date formats (known as international support)

Source Advanced MS-DOS Programming By Ray Duncan


What can I do instead?

A possible workaround would be to capture the screen (as text) and parse the output.

The answers to this question Screen capture in DOS list some TSR (Terminate but Stay Resident) programs that are starting points for you to investigate.

DavidPostill

Posted 2016-08-24T21:58:55.563

Reputation: 118 938

13Nice answer. Only the truest of Super Users would care at all about MS-DOS 1.0. – I say Reinstate Monica – 2016-08-24T23:00:38.563

Thank you for your answer, I appreciate it but I want to find a way (say using virtual box functions) that is why I will not mark It as answer for the moment. – Blake – 2016-08-25T07:04:48.443

@Blake Possible workaround would be to capture the screen (as text) and parse the output. I have updated the answer. – DavidPostill – 2016-08-25T07:37:02.293

I am sorry in advance for the delay of the results when trying to use this tsr programs. As soon as I get access to my machine I will let you know. It is great alternative and I am hoping so much to work properly. Is it necessary to install any other programs (which for example creates this tsr environment)? – Blake – 2016-08-25T08:01:56.770

1@Blake Not that I can remember, but it is many years since I used DOS. Don't worry about the delays in you testing ;) – DavidPostill – 2016-08-25T08:04:19.803

Nope, they don't work. There is a high chance of me doing it wrong but also some of them are developed later and maybe don't support it. Is batch programming enabled in 1.x and if so can you execute command assigned to a variable and then write it on a file using batch commands? – Blake – 2016-08-25T11:26:30.100

@Blake "can you execute command assigned to a variable and then write it on a file using batch commands" no. redirection is not supported. – DavidPostill – 2016-08-25T11:28:52.173

Well it seems that is the end of this issue. I will try something else for example virtual box screenshots somehow on change and see if anything happens. Thank you. – Blake – 2016-08-25T11:44:19.173

Not only would you need to find a TSR screen capture program but also it needs to use INT 27 instead of INT 21 / AH 31 as keep process was added later (2.0 I think). This was very long ago but wasn't INT 27 more popular with viruses and the latter with normal programs? I have a hard time remembering, I don't think I wrote a TSR in the last two decades. – chx – 2016-08-25T12:06:12.803

Did CTTY exist back in the DOS 1.x days? – DDay – 2016-08-25T12:55:27.177

@DDay No. Type: Internal (2.0 and later) Source CTTY

– DavidPostill – 2016-08-25T12:58:48.870

@chx: The TSRs I've written have all used INT 27h. I think the other form added some more precise control over some operational details, but I've never needed to exercise it. – supercat – 2016-08-25T17:40:07.277

-3

You could install C and write a program to take the dos commands, run them in a shell and log the results. I would recommend that you use Borland Turbo C 2.01. You can also write code in Quickbasic if you are looking to write code... ;-)

https://archive.org/details/msdos_borland_turbo_c_2.01

Personally, I would use DOS 5.5 or 6 given that there are a few additional things that you would get.

Gandolf989

Posted 2016-08-24T21:58:55.563

Reputation: 95

1Do this work in v1.25? – Blake – 2016-08-25T19:14:58.487

And if so, can you give me some additional help on installing C and how to log the results, thank you very much. – Blake – 2016-08-25T19:25:12.793

1@Blake it does not work in v1 – edc65 – 2016-08-25T20:25:18.873

Using C to write a program would be a helpful answer, if it mentioned the APIs that you would use when writing such a program. (And, of course, took into account the explicit requirement in the question that the code be compatible with DOS 1.x.) This answer does neither. It just spams a link to a popular compiler/IDE package, with no guidance on the relevance of such a toolset. – Cody Gray – 2016-08-26T11:51:14.420

The C compiler has facilities for stdin and stdout and it can run shell commands. I don't know which compiler would work in DOS 1. If you are so concerned about maintaining the board, a better question would be why would anyone write code for MS DOS 1... – Gandolf989 – 2016-08-26T22:14:40.560

Here is a page full of C compilers. Maybe one will work. I am still curious as to why someone writes code for DOS 1.25. http://www.compilers.net/dir/free/compilers/ccpp.htm

– Gandolf989 – 2016-08-29T13:51:28.987