I recently have to use some DOS command to do my task. (The stupid Windows environment)
This remind me the very first days of using computers when I was in university in 1993.
Crazy for knowledge, we bought books about DOS commands and tried to remember most of the commands and their options. We even brag to others for knowing more commands and command line options. However, without enough knowledge of operation system, it is sometimes really hard to understand the concepts beneath those commands.
Return to my topic.
I found that we can use the following command sequence in DOS to debug the execution of your DOS program running in a subprocess, such as using system function in Perl or os.system function in Python.
cmd /K "the_program && pause && exit 0"
/K means the DOS window will remain open after the program execution.
Why not just use
cmd /K "the_program" to execute your program.
The problem with the latter is:
if your program executes successfully, but the DOS window is closed by clicking the "close" button at the right corner of the title bar, your parent process will receive a False return value.
By using the first one, if the program executes successfully, user will see a "press enter to continue ..." message at the end of the execution. User may check the execution results and press enter to exit, then the return value to parent process is 0. If the program aborted, user may use the "close" button to close the DOS window and the parent process will receive the "anticipated" False value. In this case, user can see the program execution procedure while the parent process will get correct return values.
One caveat, if users still use the "close" button to close the DOS window even when they see the "press enter to continue ..." message, the parent process will still receive a False value. Sigh ... Stupid ... you know ...