来自 C# 的 Unix 命令
是否有 Unix shell 和命令作为 .Net 程序集的实现。 这可以是 cygwin 的包装器,也可以是从公共域源构建的独立版本。 我真正希望能够使用的命令类型是 wc、tar、cpio、ps、kill、cat、at ...
此操作(伪代码)有多酷
使用 cygwin 执行
......
Shell myShell = new Shell("cat file1 file2 >> file3");
myShell.Run(DateTime.Now);
编辑> 我可以看到这种方法是有效的,我自己过去也使用过这种方法。 然而,它只是感觉很难看,它是另一个正在运行的进程,它不安全,它需要在客户端计算机上进行另一个安装,你必须处理构建命令字符串。 作为进一步的例子
Shell myShell = new Shell();
myShell.Infiles.Add (streamObject);
myShell.Outfiles.Add (streamObject);
myShell.Stderr.NewOutput += myErrorLogger();
等
Is there an implementation of a Unix shell and commands as a .Net assembly. This could be a wrapper around cygwin, or a standalone built from public domain source. The kind of commands I'd really like to be able to use are wc, tar, cpio, ps, kill, cat, at ...
how cool would it be to do this (Pseudo code)
usng cygwin
.....
Shell myShell = new Shell("cat file1 file2 >> file3");
myShell.Run(DateTime.Now);
Edit > I can see the shell out approach working, I've used that approach myself in the past. However, it just feels ugly, it's another process running, it's not secure, it requires another install on client machines, you have to muck around build command strings. As a further example
Shell myShell = new Shell();
myShell.Infiles.Add (streamObject);
myShell.Outfiles.Add (streamObject);
myShell.Stderr.NewOutput += myErrorLogger();
etc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你看过PowerShell吗? 使用 Unix 命令的许多任务可以是 翻译成PowerShell。
Have you looked at PowerShell? Many tasks using Unix commands can be translated into PowerShell.
也许像下面这样的事情就可以了。
但是,我没有环境来测试它。
试一试。
Probably something like the following will do.
But, I don't have an environment to test it.
Give it a try.
我不知道任何实现,但我认为你有一个有趣的想法:)对于某人开发 busybox 可以在自己的控制台中运行,并可由 .NET 程序集使用,如示例代码中所示。 但这样的东西真的对很多人有用吗?
I don't know of any implementations, but I think what you have is an interesting idea:) Would be a fun project for someone to develop a managed version of busybox that can run in its own console and be consumable by a .NET assembly like in your sample code. But would something like this really be useful to many people?