I was created a .bat file to run PuTTY and it successfully runs. The problem now is, the command line I was key in were not executed, any solution for this?
My .bat command is:
putty -telnet -P 15555 test-PC -m C:\Users\tslai\Desktop\commands.txtI'm connecting using Telnet, and I have a specific port number, which is 15555, the server name's is test-PC. commands.txt is the arguments that I make.
In commands.txt: only have a arguments, and it was tested can work properly if running directly by using command prompt.
2 Answers
The -m command-line switch of PuTTY works for the SSH only, not for the Telnet.
See PuTTY documentation (emphasis mine):
3.8.3.6
-m: read a remote command or script from a fileThe -m option performs a similar function to the ‘Remote command’ box in the SSH panel of the PuTTY configuration box (see section 4.18.1). However, the
-moption expects to be given a local file name, and it will read a command from that file.
There's no way to execute a command on the server automatically with PuTTY over the Telnet protocol.
Though you might be able to use Plink (PuTTY command-line connection tool).
As with PuTTY, you cannot use the command parameter as that works with the SSH only.
But you might be able to use input redirection:
plink.exe -telnet -P 15555 test-PC < C:\Users\tslai\Desktop\commands.txt 0 The Telnet Scripting Tool is a program that provides the capability to script telnet sessions. Perhaps it would be a viable alternative for you.