通过与 Plink 的串行连接在设备上执行命令 [英] Execute a command on device over serial connection with Plink

查看:105
本文介绍了通过与 Plink 的串行连接在设备上执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试编写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.

这是我尝试过的命令.

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

在我从键盘上按下额外的Enter"键后,我看到设备名称的弹出窗口,这意味着连接部分已准备就绪,

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 ?

谢谢,

杰克

推荐答案

在 Plink 命令行(或使用 -m 开关)指定命令仅适用于 SSH,不适用于串行(或其他) 连接.原因是这些连接没有用于执行命令的接口.他们只有输入/输出.所以你可以改用输入重定向,比如:

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

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

这篇关于通过与 Plink 的串行连接在设备上执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆