I have written my first bash script which salvages historic 6800 mdos files currently stored on a large collection of 8-inch floppy disks. The script supplies arguments to an executable file that [a] lists files on the disk image then [b] gets each file one by one and saves it to a directory on the hard drive. The executable is compiled from source code written by Joseph H Allen.
C:/TEST/mdos.exe floppy.img ls -1 > filelist # list filenames one per line ;
while read -r name; do
echo -e "${name}"
C:/TEST/mdos.exe floppy.img get $name C:/TEST/MDOS/$name > loadstart # capture load & start addresses
done < filelist
Files successfully recovered from a single floppy disk image are shown here.
I'm now trying to document the archiving process by capturing the two interleaved strings of stdout
that appear on the screen whenever the script runs. These strings originate in two separate lines where the executable is run.
The first lists all filenames found on the disk image in response to an ls
argument supplied to the mdos.exe
at run time. Each filename appears on successive lines.
C:/TEST/mdos.exe floppy.img ls -1
The second displays load and start addresses that some mdos 6800 command files used at run time.
C:/TEST/mdos.exe floppy.img get $name C:/TEST/MDOS/$name
On the screen both streams are interleaved like so
a.lo
Load=$2000, Start=$2000
a.sa
ad571.cm
Load=$6000, Start=$6000
sd571c.sa
b2716.cm
Load=$2000, Start=$2002
...
Whenever there's a load address start address message it would make more sense on a printed log if it appeared on the same line as the file that reported it, like so
desired format
a.lo Load=$2000, Start=$2000
a.sa
ad571.cm Load=$6000, Start=$6000
ad571c.sa
b2716.cm Load=$2000, Start=$2002
...
I have so far managed to save the first stdout
stream to file but not the second.
While I understand arguments for avoiding ls
presented in posts here here and here, the part of my script that currently works uses ls
, an argument required by mdos.exe
. Unfortunately it happens to be spelt the same way and is functionally similar to ls
in Linux. I really can't tell if that is causing the obvious problem : how to capture the load and start addresses. Ultimately I need to capture both stdout
streams and present them on the same line in the desired print format (above). Looking at posts here here here and here it seems like I should be using an associative array to do this instead of writing two separate files.
If this is the best way to proceed, how would this be done as a single loop ? or should it use a separate loop to capture each stream ?