2
votes

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

1
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
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
(by editing the question, obviously) - Martin Prikryl

1 Answers

0
votes

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: