从windows发送shell命令到Linux [英] Send shell command to Linux from windows

查看:85
本文介绍了从windows发送shell命令到Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我需要从windows应用程序发送一个shell脚本/或简单shell命令(c#)

到linux服务器。 Linux服务器只会执行它。





我该怎么做?

我可以用cygwin做到这一点吗?或其他任何东西。



请尽快帮助我。



提前致谢。

Hello,

I need to send a shell script/ or simple shell command from windows application (c#)
to linux server. Linux server will just execute it.


how can I do this?
can I do this using cygwin? or anything else.

please help me in asap.

Thanks in advance.

推荐答案

这个问题让我怀疑你有足够的经验或基本的技术理解来解决这个问题,即使它相对简单。



您需要拥有应该扮演网络服务器角色的Linux应用程序,以及Windows C#应用程序 - 它的客户端。请求将发送命令。现在,它可以在几个不同的级别上完成。一种(非常无痛)的方式是:在.NET中创建客户端和服务器端,您可以在 TcpClient / TcpListener ,经典远程处理或WCF级别使用套接字。您可以在Linux上运行服务器端应用程序而无需重新编译使用Mono:

http://en.wikipedia.org/wiki/Mono_%28software%29 [ ^ ],

http:// www .mono-project.com / [ ^ ]。



另一种基于Mono的变体:安装Apache和mod_mono( http:// www .mono-project.com / [ ^ ],< a href =http://www.mono-project.com/Mod_mono> http://www.mono-project.com/Mod_mono [ ^ ])并在Linux上创建一个带服务器端的ASP.NET应用程序。在这种情况下,即使任何Web浏览器也可以扮演客户端的角色。从这里开始: http://www.asp.net/get-started [ ^ ]。客户端也可以是使用 HttpWebRequest 在Linux上使用Web服务器的常规C#Windows应用程序,请参阅:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx [ ^ ],

http://msdn.microsoft.com/en- us / library / system.net.webrequest.aspx [ ^ ](参见代码示例)。



还有许多其他变种。例如,您可以在Linux上实现使用soap的Web服务:

http://en.wikipedia .org / wiki / Web_Service [ ^ ],

http://en.wikipedia.org/wiki/SOAP [ ^ ]。



A精益解决方案既可以在Linux上使用原始套接字,也可以在Linux上使用本机编程,可能是C ++,但是对它的支持(相同应用程序级协议的实现)可能更难以兼顾,因为这两个部分都是CLR。



-SA
The question makes me doubt that you have enough experience or basic understanding of technology to get to such problem, even though it is relatively simple.

You need to have Linux application which should play a role of network server, and Windows C# application — its client. A request would be sending a command. Now, it can be done on several different levels. One (very painless) way would be: create both client and server side in .NET where you can use sockets on the level of TcpClient/TcpListener, classical remoting or WCF. You can run a server-side application on Linux without recompilation using Mono:
http://en.wikipedia.org/wiki/Mono_%28software%29[^],
http://www.mono-project.com/[^].

Another variant based on Mono: install Apache and mod_mono (http://www.mono-project.com/[^], http://www.mono-project.com/Mod_mono[^]) and create an ASP.NET application with server side on Linux. In this case, even any Web browser can play the role of the client. Start here: http://www.asp.net/get-started[^]. A client can be also a regular C# Windows application using HttpWebRequest to work with a Web server on Linux, see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^] (see the code sample).

There a are a number of other variants. For example, you can implement Web Service on Linux which would use soap:
http://en.wikipedia.org/wiki/Web_Service[^],
http://en.wikipedia.org/wiki/SOAP[^].

A lean solution can use raw sockets on both part and native programming on Linux part, presumably C++, but support of it (implementation of identical application-level protocol) could be more difficult that is both parts are CLR.

—SA


WinSCP [ ^ ]可以为您提供帮助。
WinSCP[^] could help you.


这篇关于从windows发送shell命令到Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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