如何使用批处理打开腻子并登录然后在 bash 上执行命令列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36979376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open putty using batch and login then execute list of commands on bash
提问by shareef
I have a Sun OS server with oracle configured on it ; with database 11g i want to take backup , now am connecting to terminal using ssh on putty console but , what i need is finding a way to make it possible to connect using batch to ssh to the server then login then login to oracle then take the backup, is that possible and how.
我有一个配置了 oracle 的 Sun OS 服务器;对于数据库 11g,我想进行备份,现在我在 Putty 控制台上使用 ssh 连接到终端,但是,我需要的是找到一种方法,可以使用批处理连接到 ssh 到服务器,然后登录,然后登录到 oracle,然后使用备份,这是否可能以及如何。
回答by shareef
If you really want to use putty to do this you can use the below in your command prompt in Windows(this will open the putty and its terminal and execute the passed argument in you text file):
如果您真的想使用 putty 来执行此操作,您可以在 Windows 的命令提示符中使用以下命令(这将打开 putty 及其终端并执行文本文件中传递的参数):
putty.exe plink -ssh -load profileName -l username -pw password -m commandPath -t
Or
或者
putty.exe -ssh username@ip -pw password -m commandPath
e.g:
例如:
putty.exe -ssh [email protected] -pw rootzpass -m c:\commands\mycommands.txt
Where profileNameis the profile saved in putty and the commandPathis your local directory text file containing the commands you want to execute and the usernameis the server user and ipis the IP address for the server , the passwordis your server password then you can put whatever commands you want in your textFile.
其中,profileName是保存在 putty 中的配置文件,commandPath是包含您要执行的命令的本地目录文本文件,用户名是服务器用户,ip是服务器的 IP 地址,密码是您的服务器密码,然后您可以把你想要的任何命令放在你的 textFile 中。
Referencethe.earth putty documentation