I have written a bat file in which I have the following:
putty.exe -t -load "ABC" -l username -pw password -m "C:\Users\pathasai\Desktop\abc.txt"
In my abc.txt I have written some commands which I want to be executed on PuTTY itself, but when I run the bat file, I am not able to run the commands. I am getting the error command not found. For instance, let us say our abc.txt has just one command: pbrun
. It is saying command not found. (I get this error on the putty terminal.)
How do I get multiple commands to run one after the other from the abc.txt file?
Best Answer
You can't log-in to PuTTY. PuTTY is an SSH client application which has no authentication.
You can use PuTTY to log-in to a server computer which is providing an SSH service. Typically this would be a Linux server. It is the server that requires you log-in to it.
You cannot run arbitrary commands on PuTTY itself.
You can use PuTTY to run commands in a shell on the server.
Those commands must be present on the server and supported by the server's operating system.
That means that the command
pbrun
is not a valid command on the server's operating system (this is nothing to do with PuTTY).Not all Linux servers have
pbrun
:You must also be careful with line-endings on your commands. Windows files edited with notepad are likely to have lines ending with the two ASCII control characters Carriage-Return (CR or Control-M or ^M) and Line-Feed (LF or Control-J or ^J). I would expect PuTTY to take care of this, but it may not (I have not tested this).
Update
I used Notepad to create this file, "commands.txt":
I used this command:
I got this result:
I imagine there is some issue with
stty
or PuTTY settings affecting newline operation, but basically the-m
mechanism works and, with some diligent effort, I would expect to be able to make it do useful work correctly.