2

I am trying to automate sending remote commands/getting responses to a linux host with plink/putty through a serial connection. I can successfully establish the connection:

plink.exe -load "COM4"

But how can I add my commands to the above?What I am looking for is something similar to:

plink.exe -load "COM4" <command> <parameter -1> <parameter-2> ...

I have already tried:

plink.exe -load "COM4" echo <command>
plink.exe -load "COM4" <command>

and they don't seem to work! Any ideas?

Thank you

user3255590
  • 29
  • 1
  • 4
  • Possible duplicate of [Is it possible to send the content of text file over PuTTY over serial port](http://stackoverflow.com/questions/30826002/is-it-possible-to-send-the-content-of-text-file-over-putty-over-serial-port) – Martin Prikryl Jun 20 '16 at 08:04
  • Thanks for the reply Martin but I don't want to complicate things by reading from a another file. I want to see if it's possible to send the commands directly. – user3255590 Jun 20 '16 at 18:49
  • There's no mention of you not wanting to use a file, in your question. If you have such constraint, you have to make it clear. – Martin Prikryl Jun 20 '16 at 18:54
  • (by editing the question, obviously) – Martin Prikryl Jun 21 '16 at 07:16
  • Does this answer your question? [Execute a command on device over serial connection with Plink](https://stackoverflow.com/questions/51643735/execute-a-command-on-device-over-serial-connection-with-plink) – Martin Prikryl Jun 01 '21 at 16:02

1 Answers1

0

You need to use a tool that will spawn the serial comms app as a subprocess and then pipe your input/outputs to it.

'Expect' is used for controlling command line tools in this way and comes in various flavours:

Simon Peverett
  • 4,128
  • 3
  • 32
  • 37