Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   c++ code to read from batch file (http://www.programmingforums.org/showthread.php?t=14315)

cueballr Oct 31st, 2007 12:30 PM

c++ code to read from batch file
 
:-/ Could someone tell me the code to run a batch file through a c++ program please?

thanks in advance

cueballr:)

cueballr Oct 31st, 2007 1:05 PM

Re: c++ code to read from batch file
 
never mind i got it..:twisted:

DaWei Oct 31st, 2007 1:07 PM

Re: c++ code to read from batch file
 
Well, a batch file is just text. You don't bother to tell us what you want to do. It could be as simple as printing out the batch file, or executing the batch file, or it could be as complex as attempting to convert the batch file to an equivalent C++ program. My crystal is in the shop for "ball" joints, so I'm not able to read your mind right this minute.

Let me suggest that you read the "How to Post a Question" thread that is stuck at the top of this forum. If you haven't read the rules, please do that, too. There's a link there to Eric Raymond's "Smart Questions." Recommended reading.

Welcome to the community.

cueballr Nov 1st, 2007 6:43 AM

Re: c++ code to read from batch file
 
:icon_cheesygrin:haha..fair enough...okay...could you please tell me how to convert the batch file code to c++ code..if its not to much work, one more question, is it a single command to convert the whole batch file or does it have to be line by line? :-/

thanks in advance.

cueballr =]

hollystyles Nov 1st, 2007 8:04 AM

Re: c++ code to read from batch file
 
Ok you want to convert platform dependant shell commands in a batch file (which could be a linux shell script or windows DOS .bat file blah blah... these are all batch files) into C++ Source code in like one command ??? I doubt that exists very much.

Or do you want to compile a batch file into an executable?

I googled Batch File C++ converter translator and compiler. There were various hits. One that kept coming up was Quick Batch Compiler which looked interesting. I'll let you decide.

cueballr Nov 1st, 2007 8:28 AM

Re: c++ code to read from batch file
 
Im talking bout a dos .bat file, not a linux one, and i have tried the quick batch file compiler before you pointed it out to me, it worked perfectly, but it is not what i require, i want to convert the batch codes to equivalent c++ codes, and be able to view them just for my knowlegde...was wondering if anyone could help me with that..:S

thanks anyway :)

cueballr. =]

hollystyles Nov 1st, 2007 10:55 AM

Re: c++ code to read from batch file
 
What knowledge are you trying to glean ??

Do you mean you want to disassemble the batch commands to see how they actually work?

IMHO that's *hardest* way to learn.

cueballr Nov 1st, 2007 11:47 AM

Re: c++ code to read from batch file
 
:S...No... i just want the c++ equivalent of batch code...im sure that there is a way of determining that:-/

Sane Nov 1st, 2007 12:03 PM

Re: c++ code to read from batch file
 
Stop giving him a hard time, I'm pretty sure this is all he wants to know: The function "system" executes a windows batch command in C/C++.

myBatch.bat
:

echo "Hello World!"

myApp.cpp
:

int main() {
    system("echo \"Hello World!\"");
    return 0;
}


Note: The "\" is an escape character. It's used before each a quotation mark around "Hello World!" so that C++ does not think those quotations are closing the quotation that started before "echo".

Infinite Recursion Nov 1st, 2007 2:51 PM

Re: c++ code to read from batch file
 
May want to include the conio.h header file when using the system() function.


All times are GMT -5. The time now is 8:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC