I need help with the DOS EXEC function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I need help with the DOS EXEC function

rgilliesrgillies Posts: 9Member
: I'm running into this problem when I run a *.BAT file from an application I've written. It works fine until I press control-C in the middle of the batch program:
:
: During the application's execution, I use an EXEC function to call the COMSPEC (COMMAND.COM or CMD.COM) and supply the name of a batch file (LIST.BAT) to list some files. The batch files work as it should as thoughI ran LIST.BAT from the DOS's command prompt. When the batch file ends, I type EXIT and return to my application, no problem.
:
: It's when I press CONTROL-C while the LIST.BAT file pauses at the end of a full screen that the problem is encountered. When I abort the listing early that way, a file is created in my DOS directory with an arbitrary filename and it's contents are the listing produced by the LIST.BAT file.
:
: How can I prevent the creation of this file if I want to abort from a batch file using CONTROL-C?
:

Comments

  • ranged2003ranged2003 Posts: 8Member
    : : I'm running into this problem when I run a *.BAT file from an application I've written. It works fine until I press control-C in the middle of the batch program:
    : :
    : : During the application's execution, I use an EXEC function to call the COMSPEC (COMMAND.COM or CMD.COM) and supply the name of a batch file (LIST.BAT) to list some files. The batch files work as it should as thoughI ran LIST.BAT from the DOS's command prompt. When the batch file ends, I type EXIT and return to my application, no problem.
    : :
    : : It's when I press CONTROL-C while the LIST.BAT file pauses at the end of a full screen that the problem is encountered. When I abort the listing early that way, a file is created in my DOS directory with an arbitrary filename and it's contents are the listing produced by the LIST.BAT file.
    : :
    : : How can I prevent the creation of this file if I want to abort from a batch file using CONTROL-C?
    : :
    :
    :
    Hi!
    May I know what is inside of the LIST.BAT that you've created? After that I'll study its syntax. ok! and show me an examples of an arbitary filename. I suggest to try to run that batch file not under the windows environment or in dos prompt. Try to execute that in MS-DOS mode to see if can prevent the creation of that file.

    Ranged

  • rgilliesrgillies Posts: 9Member
    [b][red]This message was edited by rgillies at 2003-1-20 19:53:26[/red][/b][hr]
    [b][red]This message was edited by rgillies at 2003-1-20 19:50:5[/red][/b][hr]
    : Hi!
    : May I know what is inside of the LIST.BAT that you've created? After that I'll study its syntax. ok! and show me an examples of an arbitary filename. I suggest to try to run that batch file not under the windows environment or in dos prompt. Try to execute that in MS-DOS mode to see if can prevent the creation of that file.
    :
    : Ranged
    :
    Hi there Ranged. What I'm trying to do is list the newest files in the current working directory, using wildcards. The BAT file in it's entirety contains this text:

    DIR G*.* /O:-D | MORE

    The happy emoticon is supposed to be a colon-dash-D, but this web page seems unable to distiguish it from that for some reason.

    There is no other OS on the computer other than DOS ver6.22 itself. It's a pure DOS booting computer.


    Bob





  • ranged2003ranged2003 Posts: 8Member
    : [b][red]This message was edited by rgillies at 2003-1-20 19:53:26[/red][/b][hr]
    : [b][red]This message was edited by rgillies at 2003-1-20 19:50:5[/red][/b][hr]
    : : Hi!
    : : May I know what is inside of the LIST.BAT that you've created? After that I'll study its syntax. ok! and show me an examples of an arbitary filename. I suggest to try to run that batch file not under the windows environment or in dos prompt. Try to execute that in MS-DOS mode to see if can prevent the creation of that file.
    : :
    : : Ranged
    : :
    : Hi there Ranged. What I'm trying to do is list the newest files in the current working directory, using wildcards. The BAT file in it's entirety contains this text:
    :
    : DIR G*.* /O:-D | MORE
    :
    : The happy emoticon is supposed to be a colon-dash-D, but this web page seems unable to distiguish it from that for some reason.
    :
    : There is no other OS on the computer other than DOS ver6.22 itself. It's a pure DOS booting computer.
    :
    :
    : Bob
    :
    :
    Hi!

    There is nothing wrong with your code because I'll try it too and I try also when I press ctrl+c to terminate the batch file and nothings happen. No arbitary filename was created. Maybe our operating system are different. I am using dos 7.0 higher thatn 6.22. I hope my reply gives u an idea how the problem arise.

    ranged
  • rgilliesrgillies Posts: 9Member
    : Hi!
    :
    : There is nothing wrong with your code because I'll try it too and I try also when I press ctrl+c to terminate the batch file and nothings happen. No arbitary filename was created. Maybe our operating system are different. I am using dos 7.0 higher thatn 6.22. I hope my reply gives u an idea how the problem arise.
    :
    : ranged
    :
    Thank you for the assistance in verifying this as a side effect in my system. I think it points more to a better programming solution that I should employ. It might be a problem in how the EXEC routine is set up by me, in the compiler bindings or even how DOS 6.22 handles keyboard interrupts itself. Who knows. The bottom line is that for whatever reason the file was created, something wasn't handled properly and my code (or lack thereof) simply exacerbates that side effect.

    I'll have to make the .BAT file smarter (make it menu driven) to intercept a Control-C keyboard interrrupt perhaps as a first solution, if that's even possible, and see if that narrows the source of the side effect.

    Bob
Sign In or Register to comment.