3
1
I have a sequence of commands which I use to update the firmware on my Linux machine. When I connect to the machine using a serial connection I can type the commands one-by-one and they work fine. I would like to automate this procedure by running the commands in a batch file.
I have a profile for my serial connection saved as 'i5IS-COM4' so I run my first batch file , 'send.bat' , which reads:
commands.bat | putty -load i5IS-COM4
and commands.bat reads:
echo "this command works!"
When I run 'send.bat' it correctly opens a terminal and connects to my Linux machine but the echo command is not working. If anyone could help me get my batch file to work it would be greatly appreciated!
I have looked over the following post and a number of others, but I have yet to find a solution to my problem.
Run multiple commands from a file after logging into PuTTY from a bat file
edit:
When I use command redirection using plink instead of putty, I just get an empty terminal. Running the following command:
start plink.exe -load i5IS-COM4 < commands.txt
with commands.txt as follows:
echo "this command works!"; /bin/bash
returns the following terminal:
Thanks for your response Martin. I have used plink instead of PuTTY and I am able to get a terminal open, but neither the syntax you have posted, nor 'start plink.exe -load i5IS-COM4 < commands.bat' have successfully run my commands. – foxymop – 2018-04-17T17:44:57.173
So what did it do? Show us. – Martin Prikryl – 2018-04-18T05:55:36.927
I open a terminal and log into my linux server, then I run the batch file containing the following line:
start plink.exe -load i5IS-COM4 < commands.txt
commands.txt contains the following line:echo "this command works!"; /bin/bash
When I run the batch file I just get a blank plink terminal and if I hit enter I get a prompt from the root user. – foxymop – 2018-04-18T17:30:07.997Why
start
? That does not make sense. Remove it. – Martin Prikryl – 2018-04-18T18:29:01.990Thanks Martin! I just had to remove the 'start' from my file and change the line endings to Unix in my text editor, now I am able to run a sequence of commands through plink! – foxymop – 2018-04-18T20:29:53.567