通过Windows上的腻子在SSH上编写脚本 [英] Scripting over ssh through putty on windows
问题描述
我需要编写从Windows计算机上恢复Linux计算机的mysql脚本.我有腻子,我知道它具有ssh功能.这是我所拥有的:
I need to script a mysql restore of a linux machine from a windows machine. I have putty and I know it has ssh capability. Here is what I have:
C:\Progra~1\Putty\putty.exe -ssh root@10.1.2.3 && mysql -u USER -pPASS db < /tmp/dump.sql
我在编写脚本时遇到的问题是,腻子会打开一个新窗口并在其中转移控制权,所以之后便会发生任何事情
My problem in writing a script is that putty opens a new window and transfers control there, so anything coming after
putty.exe -ssh
什么都不做.
推荐答案
您可以使用-m
选项指定一个文件,该文件包含要在远程连接上运行的命令.
You can use the -m
option to specify a file which contains a command to run on the remote connection.
示例:
C:\Progra~1\Putty\putty.exe -ssh -m C:\cmd.txt root@10.1.2.3
C:\cmd.txt
mysql -u USER -pPASS db < /tmp/dump.sql
从油灰文档:
3.8.3.6`-m':从文件中读取远程命令或脚本
3.8.3.6 `-m': read a remote command or script from a file
-m' option performs a similar function to the
远程命令"
PuTTY配置框的SSH面板中的框(请参阅部分
4.18.1).但是,`-m'选项将被赋予一个本地文件名,它将从该文件中读取命令.
The -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 `-m' option expects to be given a local file name, and it will read a command from that file.
对于某些服务器(尤其是Unix系统),您甚至可以 此文件中多行,并在其中执行多个命令 顺序或整个shell脚本;但这可以说是一种虐待,并且 不能期望它在所有服务器上都能正常工作.特别是众所周知 不与某些嵌入式"服务器(例如思科路由器)一起使用.
With some servers (particularly Unix systems), you can even put multiple lines in this file and execute more than one command in sequence, or a whole shell script; but this is arguably an abuse, and cannot be expected to work on all servers. In particular, it is known not to work with certain `embedded' servers, such as Cisco routers.
此选项在文件传输工具PSCP和 PSFTP.
This option is not available in the file transfer tools PSCP and PSFTP.
这篇关于通过Windows上的腻子在SSH上编写脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!