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:
- hangs until you press Enter, after that you will have "login:", and will not exit
- the command doesn't work (doesn't create a dir)
PS I am using Plink on a windows machine.
CodePudding user response:
- Use
echo.
to send empty line = Enter - Another
echo
to send the login - In Windows (contrary to *nix shells), if you do
echo "foo"
, you get"foo"
, notfoo
. So you might needecho mkdir ...
, notecho "mkdir ..."
.
(
echo.
echo username
echo mkdir /test
timeout /t 5 > nul
taskkill /f /im plink.exe > nul
) | plink ...