I am using a TCPIP connection to communicate over port 23 (telnet) to
a server,
and I am having to mimic normal command line interface you owuld see
in a telnet session (i.e. I have to write to this socket just like you
would enter things on the keyboard if you telneted to this server).
In a normal telnet session you can enter some commands which take a
long time to complete, and they run in the background and you get the
command line prompt back, you can hit <ctrl-d> on the keyboard to see
the status of the background task and see if you get a response like
"EXECUTED" or "WORKIGN", when you hit the <enter> again you will be
back at the command line to continue working.
Context is C++ on a Unix server:
My problem is I cannot programatically mimic a <ctrl-d> input through
the socket when required, so that I can read the background response.
I have tried writing/sending all sort's of characters to emulate the
keyboard sequence of ctrl-d. I am surprised that I cannot find
anything in the usergroups related to this problem, perhaps control
characters are most usually read but never sent?
I have tried the following, but it did not work:
const char ch='^D';
ptr=&ch[0];
size=1;
nwritten = write(socketDes criptor, ptr, size); 4 13963
Scott wrote:
.... I have tried writing/sending all sort's of characters to emulate the keyboard sequence of ctrl-d. I am surprised that I cannot find anything in the usergroups related to this problem, perhaps control characters are most usually read but never sent?
I have tried the following, but it did not work: const char ch='^D';
const char ch='\004';
ptr=&ch[0]; size=1; nwritten = write(socketDes criptor, ptr, size);
nwritten = write(socketDes criptor, &ch, size);
Maybe ?
Scott wrote: I am using a TCPIP connection to communicate over port 23 (telnet) to a server, and I am having to mimic normal command line interface you owuld see in a telnet session (i.e. I have to write to this socket just like you would enter things on the keyboard if you telneted to this server).
In a normal telnet session you can enter some commands which take a long time to complete, and they run in the background and you get the command line prompt back, you can hit <ctrl-d> on the keyboard to see the status of the background task and see if you get a response like "EXECUTED" or "WORKIGN", when you hit the <enter> again you will be back at the command line to continue working.
Context is C++ on a Unix server: My problem is I cannot programatically mimic a <ctrl-d> input through the socket when required, so that I can read the background response.
I have tried writing/sending all sort's of characters to emulate the keyboard sequence of ctrl-d. I am surprised that I cannot find anything in the usergroups related to this problem, perhaps control characters are most usually read but never sent?
I have tried the following, but it did not work: const char ch='^D';
those are 2 characters. '^' followed by the character 'D'
ptr=&ch[0]; size=1; nwritten = write(socketDes criptor, ptr, size);
you need to send the character code for your system
On an ASCII system that would be
const char ch = 0x04;
ctrl a -> 0x01
ctrl b -> 0x02
ctrl c -> 0x03
....
--
Karl Heinz Buchegger kb******@gascad .at
klaas wrote:
[SNIP] use EOF, it's a sumbolis integer constant defined in <iostream>,
[SNIP]
sumbolis as symbolic?
--
WW aka Attila
klaas wrote: My problem is I cannot programatically mimic a <ctrl-d> input through the socket when required, so that I can read the background response.
I have tried writing/sending all sort's of characters to emulate the keyboard sequence of ctrl-d.
control-d on unix means end-of-file on windows this would be control-z
if you want it, you can use #include <iostream>
using std::flush;
socket_or_howev er_your_interfa ce_is << EOF << flush;
This has basically no chance of working. EOF is an integer. This will
print a string representation of it's value. Try it.
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Miky |
last post by:
Hi,
I need to send Ctrl-PgUp (or Ctrl-PgDown) to the active
application but when I use SendKeys.Send("^{PGUP}"), the
program understands it as just PageUp. How may I solve it?
Thanks in advance,
LDV-ME.
|
by: ThomasG |
last post by:
Hi,
i've got a main (win-)application which starts a consoleapp to do some work:
Dim psi As New ProcessStartInfo
psi.UseShellExecute = False
psi.CreateNoWindow = True
psi.RedirectStandardInput = True
psi.RedirectStandardError = True
psi.RedirectStandardOutput = True
|
by: Hugh Janus |
last post by:
Hi,
I am running a DOS script in memory using a thread. However, if I want
to interrupt this script and stop it, what should I do? In a normal
DOS window you'd press CTRL+C but I do not have the DOS window.
Aborting the thread works but throws an error that I then have to
capture. Ideally, i'd like to somehow send the key sequence CTRL+C...
|
by: mule |
last post by:
hello all, I have a c# app that telnets into a router and issues a
series of commands. All works great except I haven't figured out how to
send a CTRL+C. I need this so I can kill a program that tends to get
hung.
Thanks!
|
by: s99999999s2003 |
last post by:
hi
i have a program that works very similar to tail -f in Unix
It will need a Ctrl-C in order to break out of the program.
I wish to run this program using python (either thru os.system() or
some other subprocess modules) and how can i pass Ctrl-C to this
program to terminate it in python?
thanks
| |
by: s99999999s2003 |
last post by:
hi
i have a program that works very similar to tail -f in Unix
It will need a Ctrl-C in order to break out of the program.
I wish to run this program using python (either thru os.system() or
some other subprocess modules) and how can i pass Ctrl-C to this
program to terminate it in python?
thanks
|
by: William Stacey [MVP] |
last post by:
How do you send Ctrl-C to a standard input stream? Just sending 03 does not
work.
--
William Stacey
|
by: cartoper |
last post by:
I am in a pickel, I MUST start and stop the apache web server in
console mode. The only way to shut down apache cleaning is by
pressing <Ctrl>+C. I have tried everything I know and I cannot
duplicate that in C# code. This is what I have, which is NOT working:
public static extern bool GenerateConsoleCtrlEvent(int ctrlEvent, int...
|
by: Daniel Clark |
last post by:
I have a Windows command line based application that only shuts down
cleanly if it sees "CTRL-C" on the console. I need to automate the
running of this application, but still allow the user sitting at the
machine to cancel the process cleanly if he/she needs to. In Unix this
would be a tiny shell script that used "kill -15", but under Windows...
|
by: rhitam30111985 |
last post by:
Hi all .. i am trying to do something really weird ...
here is my code :
import os
os.system("mail -s test xxx@gmail.com asdaskdjkasdaasdad")
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |