在使用Plink将登录信息和命令发送到串行端口之间等待 [英] Wait between sending login and commands to serial port using Plink

查看:129
本文介绍了在使用Plink将登录信息和命令发送到串行端口之间等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过PLINK中的串行端口进行连接.问题在于(下面的)代码不起作用,因为文件remove.txt一次发送,而终端正在要求登录时并且在它开始要求命令之前.有没有可能先登录然后执行命令文件? test已保存的串行会话(com5波特115200)

I want to make connection by serial port in PLINK. The problem is that the code (below) doesn't work because file remove.txt is all sent at once, while terminal is asking for a login and before it starting asking for commands. There is any possibilities to login first and then execute command file? The test is saved serial session (com5 baud 115200)

命令:

C:\PROGRA~1\PuTTY\plink -load test < C:\Users\qj2p70\Desktop\remove.txt

remove.txt文件:

root
root
cd /cfg_usr/delphi/etc
rm vip_coding_yes

推荐答案

如果我理解正确,那么问题在于串行端口上的设备会丢弃输入为时过早的输入.

If I understand correctly, the problem is that the device on the serial port discards an input that comes too early.

您可以通过在各个输入/行之间暂停来解决此问题.但是,那么您将无法使用输入文件.您需要使用程序"生成输入,该程序可以执行暂停操作并将输入的内容传输到plink.实现此类程序的一种简单方法是在批处理文件中使用复合语句:

You can solve that by pausing between individual inputs/lines. But then you cannot use an input file. You need generate the input using a "program" that can do the pauses and pipe that input to plink. An easy way to implement such program is using a compound statement in a batch file:

(
  echo root
  timeout /t 5 > nul
  echo root
  timeout /t 5 > nul
  echo cd /cfg_usr/delphi/etc
  timeout /t 5 > nul
  echo rm vip_coding_yes
) | C:\PROGRA~1\PuTTY\plink -load test


以上将产生Windows CRLF行结尾.也许您的设备需要* nix CR行尾.您可以尝试以下PowerShell脚本(script.ps1):

Write-Host -NoNewline "root`n"
Start-Sleep 5
Write-Host -NoNewline "root`n"
Start-Sleep 5
# ...

并像这样使用它:

powershell.exe -ExecutionPolicy Bypass -File script.ps1 | C:\PROGRA~1\PuTTY\plink -load test

这篇关于在使用Plink将登录信息和命令发送到串行端口之间等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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