简体   繁体   English

Windows 上的 Java/C#.NET 来执行 linux 操作

[英]Java/C#.NET on windows to execute linux operations

I have one application to write in C# (I can write that in Java as well) This application is basically accepts some information from user and using these information we are creating some files on Linux system (This is the idea)我有一个用 C# 编写的应用程序(我也可以用 Java 编写)这个应用程序基本上接受来自用户的一些信息,并使用这些信息我们在 Linux 系统上创建一些文件(这就是想法)

Using what libraries I can achieve this ?使用哪些库可以实现这一目标? Assumption: I do have credentials and access to the Linux machine.假设:我确实拥有对 Linux 机器的凭据和访问权限。

What is the best way to do this ?做这个的最好方式是什么 ? How can I do this with .NET and Java ?我怎样才能用 .NET 和 Java 做到这一点?

Application must be on Windows.应用程序必须在 Windows 上。 Mostly application will be developed in ASP.net/C#.net/Java (only windows)大多数应用程序将在 ASP.net/C#.net/Java 中开发(仅限 Windows)

Some examples: 1. I will be creating a file say abc.rb on one linux server.一些示例: 1. 我将在一台 linux 服务器上创建一个文件,比如 abc.rb。 2. Execute a command eg sudo app-client or any other command like "service httpd restart" 2. 执行命令,例如 sudo app-client 或任何其他命令,例如“service httpd restart”

Looks like you can achieve everything with .NET.看起来您可以使用 .NET 实现一切。 Just use ssh client to execute the commands on remote Linux machine.只需使用 ssh 客户端在远程 Linux 机器上执行命令。 You could use this library http://sshnet.codeplex.com/你可以使用这个库http://sshnet.codeplex.com/

I can't say anything about C# or .NET, but I assume it can still be tackled in a similar way to how I'd do it in Java.我不能说任何关于 C# 或 .NET 的事情,但我认为它仍然可以通过与我在 Java 中的处理方式类似的方式来解决。

Can you install an FTP Server on the Linux box?你能在 Linux 机器上安装 FTP 服务器吗?

That way, you can use a FTP Client API on whatever language you use (there are some available for Java, such as Apache Commons-net ).这样,您可以在您使用的任何语言上使用 FTP 客户端 API(有一些可用于 Java,例如Apache Commons-net )。 Firstly, I'd have my application create the files locally, based on user input, then the application will use the FTP client API to transfer them over to the Linux filesystem.首先,我让我的应用程序根据用户输入在本地创建文件,然后应用程序将使用 FTP 客户端 API 将它们传输到 Linux 文件系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM