swiftxcodesshnmssh

How to emulate keys through ssh / NMSSH


I'm looking for some help on how to simulate keys through strings / SSH. I've been using the SSH Framework NMSSH. I've got sending all the commands working through the channel.write command except one. I need to send the command Ctrl + C to abort out of something. Any idea's on how to do this? I'm not sure how to send a "Key" along with the string.


Solution

  • Ctrl-C is the character at codepoint 3. It's formally known as ETX (end of text), and it's part of the "control character" block. It's a non-printing character, so you have to express it using a special character sequence. I'm not a swift programmer, but it looks like you'd specify it like this:

    let ctrlC: Character = "\u{3}"