Wait between sending login and commands to serial port using Plink

孤街醉人 提交于 2019-12-06 16:52:47

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

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

The above will produce Windows CRLF line endings. Maybe your device needs *nix CR line endings. You can try the following PowerShell script (script.ps1):

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

And use it like:

powershell.exe -ExecutionPolicy Bypass -File script.ps1 | C:\PROGRA~1\PuTTY\plink -load test
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!