Redirect Console over Winsock

Posted on 2004-03-24
Last Modified: 2013-11-13
I was curious if anyone knew a way to redirect a console over winsock? I have a console based program that runs on Machine B. I would like to be able to telnet to Machine B from Machine A and have it like I am using the DOS window on MACHINE B.

If you need further explanation, let me know. I dont need a full example I know how to program I just need to know how to redirect the console so that it will display properly in telnet on the other side.

Question by:BrianGEFF719
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Expert Comment

ID: 10679796
you can get the command line's result with a > filename into the filename

the client sends "dir", the server does :
dir > a.txt

then just open a.txt and send the content
to the client
LVL 19

Author Comment

ID: 10681852
I cant do it like that, I need to have the program running and redirect whats going on with it. Its a DOS Program I use to manage a database on computer B and I need to be able to view the progress as if I am running the program on the computer.


Expert Comment

ID: 10684892
Stdin and stdout are available as file handles.  This is a good thing, but if the program writes directly to the console's memory it may not go through stdout.  Is all the output going to stdout?

If so, then all you have to do is start the program the same way as a CGI program is started from a web server.  The socket server starts the program with the stdin and stdout as pipes then it can read from the socket and write to the stdin pipe, read from the stdout pipe and write to the socket.

For an example of how that might work, take a look at the source for any webserver that can do CGI (Apache comes to mind since the source is available)

I may try to put together an example...

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users


Expert Comment

ID: 10684930
Does this program that converts the socket stuff into stdin and stdout have to be a VB program?  The question is in the VB section...  If it can be in C try the pipe() function in the standard library.  The Visual Studio help file even has an example for the pipe() function.


Accepted Solution

jerry_jeremiah earned 500 total points
ID: 10684970
Ok, I think I have something here.  I did a search for the words:

     stdin stdout pipe "Visual Basic"

and found:

If you do the same search you will likely find others...  Actually there is a lot of good stuff - I recommend doing the search.

LVL 19

Author Comment

ID: 10684979
Think of it like this...

Lets say I want to run FDISK over a network connection (hypothetical statement). I would want  to be able to telnet to the computer and have the computer run FDISK and redirect it back to the client so it can be displayed in a TELNET client.


Expert Comment

ID: 10702714

Here is something else that will help you.

Assuming you can make a program that:
 - starts a command line program (fdisk, cmd, etc)
 - connects to the stdin and stdout
 - provides a socket server that allows telnet-type connections

Then you need some way of starting it remotely.  It has to be running on the remote machine, so you need some way to start it on that remote machine.

So, then I found something that could do that.  But it also does what you want (e.g. run fdisk remotely and display the results locally)  Check this out:

In general, the stuff at is worth knowing about...


Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question