Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
622 views
in Technique[技术] by (71.8m points)

remote access - Execute a command on device over serial connection with Plink

This is the first time that I am trying to write a "plink" command that will connect to a device and to have a remote command executed afterwards. And I am blocked so far.

Here is the command I have tried.

plink -v device ( execute shell; whoami)

I was expecting the full command process finished right away, but somehow, it hangs. here is the screenshot after I have run the above command,

plink -v device ( execute shell; whoami) 
Opening serial device COM1
Configuring baud rate 115200
Configuring 8 data bits
Configuring 1 data bits
Configuring no parity
Configuring XON/XOFF flow control

And after i have pushed the extra "Enter" key from my keyboard, then I see the popup of device name, which means the connection part is ready,

plink -v device ( execute shell; whoami) 
Opening serial device COM1
Configuring baud rate 115200
Configuring 8 data bits
Configuring 1 data bits
Configuring no parity
Configuring XON/XOFF flow control

FX04DN4N16000408  #

What I don't understand is why do I need to run this extra manual step ?

Thanks,

Jack

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Specifying a command on Plink command-line (or with -m switch) works with SSH only, not with serial (or other) connections. The reason is that those connections have no interface for executing a command. They only have input/output. So you can use input redirection instead, like:

plink.exe ... < commands.txt

or

(
  echo your command 1
  echo your command 2
  echo your command 3
) | plink.exe ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...