This is a very simple question today, for some reason when I start a batch file with the code:
ssh [email protected]
It loops infinitely, output:
Would really appreciate it if someone knows the answer to this, if not, I will also take some different software suggestions, my requirements are: It must be able to connect through SSH to a Linux server through Windows, It can not have the capability of storing passwords, It must be able to open multiple instances of SSH connections, and I must be able to input the password and commands in manually through a terminal.
Edit: Note I named my batch file SSH.bat
CodePudding user response:
cmd
executes in the following, relevant, order:
It checks working directory itself for a file with the name only (if no extension is specified). the system variable %pathext%
displays the extensions and the order it will be searched.
If the file is not found locally, then it will move to the environment variables and try and find a command in the path.
So, in your case, the ssh.bat
file has called ssh.exe
as ssh
without extension and therefore found ssh.bat
in the current directory and then keeps calling itself, as that is what you're effectively telling it to do.
two methods of fixing this; Name the file something other than system commands or simply fully use name, path and extensions in your batch file, so you can then have ssh.bat
with C:\path\to\ssh.exe host:22
which will override checking local path as you implicitly specify the path to the executable.
CodePudding user response:
If a command loops infinitely, mostly it is caused by using the same name for the batch file than the name of the executable program. The batch file has precedence over the exe, so it starts itself