I am trying to configure a device over SSH in a automated way using a .bat
script. In the snippet below I am generating a file with the required commands in the correct order, afterwards I execute/read the file into the SSH connection using plink
. This results in a error message the the commands are unknown, I think this is caused by the fact that the commands are not executed one by one but the entire file is inserted.
Does anyone have a idea how I can execute multiple commands sequentially?
I have tried to redirect the commands.txt file into plink
without success. Also it is not possible to create a new SSH connection for each commands, because some commands turn the device into the configuration mode. Unfortunately the device that I am trying to configure is not Unix based, so chaining commands with &&
or ;
is not possible, I am required to insert the command and then 'press enter' and continue.
config.bat
@echo off
SET /P IpAdres=IP:
SET /p Username=Username:
SET /p Password=Password:
echo command 1 >> commands.txt
echo command 2 >> commands.txt
echo command 3 >> commands.txt
echo command 4 >> commands.txt
plink.exe -batch %IpAdres% -l %Username% -pw %Password% -m commands.txt