Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 15th, 2004, 1:44 AM   #1
cfriend
Newbie
 
Join Date: Jul 2004
Posts: 8
Rep Power: 0 cfriend is on a distinguished road
Hi

Is there any way to write from the same program in many command prompts ? More specifically I use win XP and MS Visual C++ v6. All we know that with a simple printf or cout we can write to the command prompt of our application. But if we want to have two command prompts running in the same application how can we redirect the print or cout output to write in the first or second command prompt ? I know the existence of system(“cmd”); function ( and also I know that is not a safe command but my application is only for me and not commercial ) . This function it only opens new commands prompts without giving the ability to write into them ? Is there any solution ? Also if there is an answer for the previous questions , how can I pass and execute some commands ( dir ,exit ) in that command prompts ?

Thanks
cfriend is offline   Reply With Quote
Old Sep 15th, 2004, 8:56 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Redirect your output to dynamically created batch files... then have an instance to execute each batfile via the cmd function.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Sep 15th, 2004, 9:15 AM   #3
Ashcroft
Programmer
 
Join Date: Sep 2004
Posts: 38
Rep Power: 0 Ashcroft is on a distinguished road
If you want to write to and/or read from a console process you can use popen (or _popen in DOS). This forks and execs a process and returns a FILE * tied to stdin, stdout, or both depending on the final arg you pass in. It works a lot like a 'system' call you can interact with programatically.
Ashcroft is offline   Reply With Quote
Old Sep 15th, 2004, 9:35 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Interesting, I'll have to look into that myself.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:01 PM.

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