使用 PuTTY 从 Windows 在 Linux 上自动运行命令 [英] Automating running command on Linux from Windows using PuTTY

查看:43
本文介绍了使用 PuTTY 从 Windows 在 Linux 上自动运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,我需要经常从 Windows 运行 a linux shell 命令(使用不同的文件名).我正在使用 PuTTY 和 WinSCP 来做到这一点(需要登录名和密码).通过WinSCP将文件复制到linux机器中的预定义文件夹,然后从PuTTY运行命令.有没有办法通过程序自动执行此操作.理想情况下,我想从 Windows 中右键单击该文件并发出将文件复制到远程机器的命令,并以文件名作为参数运行预定义的命令(在 PuTTy 中).

I have a scenario where I need to run a linux shell command frequently (with different filenames) from windows. I am using PuTTY and WinSCP to do that (requires login name and password). The file is copied to a predefined folder in the linux machine through WinSCP and then the command is run from PuTTY. Is there a way by which I can automate this through a program. Ideally I would like to right click the file from windows and issue the command which would copy the file to remote machine and run the predefined command (in PuTTy) with the filename as argument.

推荐答案

常见的自动登录方法可能存在安全问题.最简单的方法之一记录如下:

There could be security issues with common methods for auto-login. One of the most easiest ways is documented below:

至于执行命令的部分在 Putty UI 中,Connection>SSH> 有一个用于远程命令的字段.

And as for the part the executes the command In putty UI, Connection>SSH> there's a field for remote command.

4.17 SSH 面板

4.17 The SSH panel

SSH 面板允许您配置仅适用于 SSH 的选项会议.

The SSH panel allows you to configure options that only apply to SSH sessions.

4.17.1 在服务器上执行特定命令

4.17.1 Executing a specific command on the server

在 SSH 中,您不必运行服务器上的常规 shell 会话.相反,您可以选择运行单个特定命令(例如邮件用户代理,例如).如果你想这样做,输入命令远程命令"框.http://the.earth.li/~sgtatham/putty/0.53/htmldoc/Chapter4.html

In SSH, you don't have to run a general shell session on the server. Instead, you can choose to run a single specific command (such as a mail user agent, for example). If you want to do this, enter the command in the "Remote command" box. http://the.earth.li/~sgtatham/putty/0.53/htmldoc/Chapter4.html

简而言之,您的答案可能与以下文本类似:

in short, your answers might just as well be similar to the text below:

这篇关于使用 PuTTY 从 Windows 在 Linux 上自动运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆