Home > database >  Send linux commands via com port via plink and exit
Send linux commands via com port via plink and exit

Time:12-28

I need to execute one or more commands via com port (from console) on an embedded Linux device. I am trying to use plink but it doesn't work I've tried different cases, one of them is:

echo "mkdir /test" | plink -batch -serial \\\\.\\com4 -sercfg 115200,N,8 -l root

I have a couple of problems:

  1. hangs until you press Enter, after that you will have "login:", and will not exit
  2. the command doesn't work (doesn't create a dir)

PS I am using Plink on a windows machine.

CodePudding user response:

  1. Use echo. to send empty line = Enter
  2. Another echo to send the login
  3. In Windows (contrary to *nix shells), if you do echo "foo", you get "foo", not foo. So you might need echo mkdir ..., not echo "mkdir ...".
(
  echo.
  echo username
  echo mkdir /test
  timeout /t 5 > nul
  taskkill /f /im plink.exe > nul
) | plink ...
  • Related