Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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)

Command:

C:PROGRA~1PuTTYplink -load test < C:Usersqj2p70Desktop
emove.txt

remove.txt file:

root
root
cd /cfg_usr/delphi/etc
rm vip_coding_yes
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

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~1PuTTYplink -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~1PuTTYplink -load test

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...