Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I input data into a console

Status
Not open for further replies.

komyg

Programmer
Dec 13, 2005
68
0
0
BR
I have a console similiar to the Windows ms DOS prompt, and I would like to give commands to this console trough a software. How do I do this?

Thanks
 
What do you mean that you want to give commands to the console?
Are you suggesting that you want to manage colours and layout?
There is a library called "curses" that allows you to control layout and colours.
If you simply want to generate prompts and read the user responses then using stdout and stdin should suffice.



Trojan.
 
The console I need to send a command to was developed to be an interface between a network manager and a telecommunications network. The command itself will ring a buzzer in a remote location through a RF link.
I need to send this command several times in a short amount of time, so I want to write a program to do this for me.
So I need my program to communicate with the console and send it the command.
I really have no idea how to do this, so any and all help is greatly apreciated.

Thanks,
Komyg
 
I really have no idea too, but here it goes my guess.

I think the console program you have is sending a message through the network to a server listening out there, so from my point of view you have two options:

1.- Trying to know the format and transport protocol for the sent message (examining the code, with a sniffer) and write a program that can send a similar message

2.- Use a robot: that's a program that will capture and repeat user actions, like writing to a console.

Cheers,
Dian
 
Well, that's ok Trojan.
First I was trying to create a console, but I couldn't do even that. So can anyone tell me how can I create a Windows MS DOS console trough a C++ program.
On the other hand I really like the robot idea, but I don't know even where to start. Could you give me a hand Dian.

Thank you very much for your help,
Komyg
 
We need to know more about your network manager and telecoms network.
Also we need to know the command set that this "terminal" responds to.
Do you know if it is a socket based system? Does it respond to a specific protocol maybe on a specific port?


Trojan.
 
As I said, I just need to send a specific command to the console (exec ODA XXXX 1, where XXXX is the number of the buzzer I need to ring).
The console itself is started by a command in a DOS PROMPT (start wmconsole RD1), so I was thinkg about creating a DOS PROMPT and making it start the console.
As my program will be creating the PROMPT, I'll have the standard handles of the PROMPT.
These handles will be inherited by a new process created by the PROMPT (in wich case is the wmconsole).
Finally with those handles I'll probably be able input commands in the stdin of the wmconsole, making it possible to send the command to it using the WriteConsole function in windows.h.

Thanks,
Komyg
 
Now we're talking!
You need a process that can start a child process and interract with it through STDIN and STDOUT.
The obvious choice is a tool called "expect" rather than "C".


"expect" will allow you to "spawn" a child process (in your case the "wmconsole RD1" and send commands to and manage the responses.



Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top