Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Running MS-DOS within a c++ program (Code)

Reply
Thread Tools

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

 
 
Mike
Guest
Posts: n/a
 
      01-24-2006
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

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-24-2006
* 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?
 
Reply With Quote
 
 
 
 
Shark
Guest
Posts: n/a
 
      01-24-2006
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?

 
Reply With Quote
 
Kai-Uwe Bux
Guest
Posts: n/a
 
      01-24-2006
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
 
Reply With Quote
 
Peter_Julian
Guest
Posts: n/a
 
      01-24-2006

"Shark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
| 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.



 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-24-2006
* 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?
 
Reply With Quote
 
Gavin Deane
Guest
Posts: n/a
 
      01-24-2006

Peter_Julian wrote:

> "Shark" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> | 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

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      01-25-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excuting a program within a C Program CelticsROC88 C Programming 0 03-09-2010 10:32 PM
Running Java Program from a Java Program Shadow123 Java 1 07-09-2008 08:20 PM
Running a program (gperf) inside another C program Alexander Mahone C Programming 4 05-26-2008 09:31 PM
running another program from a C++ program Lorenzo Bettini C++ 3 09-24-2005 10:05 AM
Help !I want to write a program to count the running time of another program freehomesp@yahoo.com.cn C Programming 1 08-12-2005 06:13 AM



Advertisments