2

I've recently found xterm and node-pty which are great tools and have implemented them into my app. However, when I write to the terminal with xterm.write("something\r\n\") or xterm.writeln("something") the terminal goes to the next line but never actually performs the command. When typing and hitting enter in xterm itself it works perfectly.

Anyone here that can help me out?

Thanks!

  • `term.write` is only outputting stuff on the screen (display part of the terminal). To fake input data, you have to write stuff to the pty (which will be visible at STDIN of the slave process after tty processing). – jerch Feb 25 '20 at 22:50

1 Answers1

1

You can send the new line character directly to the pty process.

Example:

ptyProcess.write('\n')

You can also run a command this way assuming that ptyProcess is an instance returned by pty.spawn(...)

Phoenix Himself
  • 1,037
  • 10
  • 17
  • Thats slightly off as most standard TERMIOS settings expect the terminal to send `\r` on enter. – jerch Feb 06 '21 at 21:37