Running MS-DOS within a c++ program (Code)

Discussion in 'C++' started by Mike, Jan 24, 2006.

  1. Mike

    Mike Guest

    What i want to do is have my c++ program, run a DOS program and copy a
    script from that DOS program to a file. I simply have no idea, how, or
    if it's plausable, to run DOS within a c++ program. It's a command
    prompt, within a command prompt. Any input would be great.

    Thanks
    Brune
     
    Mike, Jan 24, 2006
    #1
    1. Advertising

  2. * Mike:
    > What i want to do is have my c++ program, run a DOS program and copy a
    > script from that DOS program to a file.
    >
    > I simply have no idea, how, or
    > if it's plausable, to run DOS within a c++ program. It's a command
    > prompt, within a command prompt. Any input would be great.


    Off topic.

    Try over in [comp.os.ms-windows.programmer.win32].

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Jan 24, 2006
    #2
    1. Advertising

  3. Mike

    Shark Guest

    Alf P. Steinbach wrote:
    > * Mike:
    > > What i want to do is have my c++ program, run a DOS program and copy a
    > > script from that DOS program to a file.
    > >
    > > I simply have no idea, how, or
    > > if it's plausable, to run DOS within a c++ program. It's a command
    > > prompt, within a command prompt. Any input would be great.

    >
    > Off topic.
    >
    > Try over in [comp.os.ms-windows.programmer.win32].
    >


    Can he not try the system() function?
     
    Shark, Jan 24, 2006
    #3
  4. Mike

    Kai-Uwe Bux Guest

    Mike wrote:

    > What i want to do is have my c++ program, run a DOS program and copy a
    > script from that DOS program to a file. I simply have no idea, how, or
    > if it's plausable, to run DOS within a c++ program. It's a command
    > prompt, within a command prompt. Any input would be great.


    As far as standard C++ is concerned, the std::system() function from
    <cstdlib> seems to be the only way to call another program from within C++.
    Maybe, something like

    std::system( "my_program.exe > my_file.script" );

    works on your platform -- but that is just a wild guess.

    If that does not work for you, you may want to resort to the use of
    (platform specific) 3rd party libraries, which are, however, off-topic in
    this group.


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Jan 24, 2006
    #4
  5. Mike

    Peter_Julian Guest

    "Shark" <> wrote in message
    news:...
    | Alf P. Steinbach wrote:
    | > * Mike:
    | > > What i want to do is have my c++ program, run a DOS program and
    copy a
    | > > script from that DOS program to a file.
    | > >
    | > > I simply have no idea, how, or
    | > > if it's plausable, to run DOS within a c++ program. It's a
    command
    | > > prompt, within a command prompt. Any input would be great.
    | >
    | > Off topic.
    | >
    | > Try over in [comp.os.ms-windows.programmer.win32].
    | >
    |
    | Can he not try the system() function?
    |

    system() is not part of the standard, hence off topic. The rule is if it
    only runs on Windows (or if it only runs on any other OS), then its
    probably off topic here. The C++ community expends a great deal of
    effort to provide a standard that applies to any OS, including those
    that are yet to be invented.
     
    Peter_Julian, Jan 24, 2006
    #5
  6. * Peter_Julian:
    >
    > system() is not part of the standard, hence off topic. The rule is if it
    > only runs on Windows (or if it only runs on any other OS), then its
    > probably off topic here. The C++ community expends a great deal of
    > effort to provide a standard that applies to any OS, including those
    > that are yet to be invented.


    You mean, system() is part of the standard, but any particular use of it
    is not.

    In addition to your comments, I don't think the system() function would
    solve the OP's problem. But I could be wrong. The problem was not very
    clearly explained.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Jan 24, 2006
    #6
  7. Mike

    Gavin Deane Guest

    Peter_Julian wrote:

    > "Shark" <> wrote in message
    > news:...
    > | Alf P. Steinbach wrote:
    > | > * Mike:
    > | > > What i want to do is have my c++ program, run a DOS program and
    > copy a
    > | > > script from that DOS program to a file.
    > | > >
    > | > > I simply have no idea, how, or
    > | > > if it's plausable, to run DOS within a c++ program. It's a
    > command
    > | > > prompt, within a command prompt. Any input would be great.
    > | >
    > | > Off topic.
    > | >
    > | > Try over in [comp.os.ms-windows.programmer.win32].
    > | >
    > |
    > | Can he not try the system() function?
    > |
    >
    > system() is not part of the standard, hence off topic. The rule is if it
    > only runs on Windows (or if it only runs on any other OS), then its
    > probably off topic here. The C++ community expends a great deal of
    > effort to provide a standard that applies to any OS, including those
    > that are yet to be invented.


    system() is entirely standard. Before calling system("send this to the
    command processor") you can find out whether a command processor is
    available.

    I believe that is done by calling system(0) which return non-zero if a
    command processor is present, zero otherwise. But I don't have a
    definitive C library reference to hand to be absolutely sure.

    Of course, how the command processor on a particular platform behaves
    in response to any particular command is outside the scope of standard
    C++.

    Gavin Deane
     
    Gavin Deane, Jan 24, 2006
    #7
  8. Mike

    Mike Guest

    Thanks for the input, I apologize if this is off topic, I understand
    the basic idea of the system function, though it doesn't allow me to
    access specific executables within specific directories. Or if it does
    i haven't discovered how to do that yet. I beleive that if I could
    access my executable then it would work. But i can't seem to access
    the proper executable. Any more ideas are great. Thanks for the input
    thus far. Again sorry this is off topic

    Brune
     
    Mike, Jan 25, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Fairbank
    Replies:
    2
    Views:
    5,469
  2. john san
    Replies:
    19
    Views:
    751
    Diez B. Roggisch
    Feb 18, 2005
  3. tomhr
    Replies:
    27
    Views:
    1,438
    Mike Wahler
    Jan 12, 2006
  4. Anonymous
    Replies:
    0
    Views:
    201
    Anonymous
    Apr 3, 2008
  5. Robert Wallace

    my own perl "dos->unix"/"unix->dos"

    Robert Wallace, Jan 21, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    295
    Michele Dondi
    Jan 22, 2004
Loading...

Share This Page