I am writing a .bat file to execute commands in putty. I need to load a saved session, then i need to enter a 'terminal id' and press enter, then i need to enter a user name and password. Can anyone help me?
-
2What have you tried? Do you have an example of what you are trying to do that you could put into the question? – Justin Pearce Jun 06 '18 at 14:10
-
You need [AutoHotKey](https://autohotkey.com/) to send key combinations to `putty`. – Sandeep Jun 06 '18 at 14:10
-
I read online about text files with @echo and to run this text file with commands in the command line after you load putty.exe – csstudent Jun 06 '18 at 14:16
-
`plink` [10 PuTTY PLINK Examples to Automate Remote Linux Commands from Windows Batch Files](https://www.thegeekstuff.com/2017/05/putty-plink-examples/) – DavidPostill Jun 06 '18 at 14:29
-
So based on what you read, what have you written so far? What specific problem are you having with the code that you have written? – EBGreen Jun 06 '18 at 14:29
-
I can see at least two other accounts that look like the Original Poster. All three are unregistered. csstudent, please register fully, then follow this link [*I accidentally created two accounts; how do I merge them?*](https://superuser.com/help/merging-accounts), merge the accounts to regain ownership of the question and stop posting "answers" that are not answers. Take our [tour] to learn how the site works. As the legitimate owner you will be able to edit the question and post comments under it. – Kamil Maciorowski Jun 06 '18 at 17:23
1 Answers
There is confusion in your question, and in some answers and comments.
A batch file is a windows command line thing(or a DOS thing) , not a linux thing.
All the examples people have given you are more for running linux commands remotely or for running a batch of linux commands. Not batch files.
If you ever try using batch files it wouldn't be in the context of a session having logged onto a linux machine.
If you want to run a batch of commands, e.g. a bash file (which has a batch of commands), or a script that runs a batch of commands, some comments mention how to do that. The duplicate question How to type commands in PuTTY by creating batch file? also wrongly mentions batch files in the question, but answers state how to run a batch of commands on a linux system you log into. Mostly if using putty or whatever ssh client, it will load a linux console (unless e.g. the remote machine is windows and running an ssh server that gives a windows command line, like bitvise winsshd). But mostly remote machines people log into tend to be linux or sometimes windows running openssh, and give a linux command line, and so one would run a bash file or script linux can run. Not a batch file.
Really you should learn how to run a batch file on a windows machine. And learn how, when on a linux machine, to run a script e.g. a bash file. And then it will be more clear to you what you want to do when you add something like logging in and automatically running a script.
- 23,380
- 43
- 145
- 225
-
I believe that both this and the linked question ask for creating *"Windows batch file that executes command[s] on an SSH server"*. Not for a command that *"executes batch file on an SSH server"*. – Martin Prikryl Jun 07 '18 at 05:22
-
@MartinPrikryl yeah but your answer in the linked question isn't explicit that you're talking about a windows batch file The only commands you mention there are `su, sh, bash, ssh, ftp` Of those, all are linux based.. none are obviously windows like dir – barlop Jun 07 '18 at 12:20