开发者

Using C# to call perl script on a Unix box

I need to execute Perl script (basically job submission) sitting on a Unix box. This needs to happen 开发者_如何学JAVAfrom a C# application sitting on a Windows box.

Is this entirely possible? If so, where do I start? Any reading material would be helpful!


You can try this nifty SharpSSH library to connect to a unix box. When connected, you can execute arbitrary commands there.


You could look at ssh to accomplish this. ssh will make a connection to a remote machine and run arbitrary commands. If you setup private/public key pairs between the two machines then you can do this without needing an interactive prompt.

There may be ssh libraries for .net out there as well which would probably be cleaner than calling an external program.

The best known implementation of ssh for windows is probably putty which you can find here


This is more of an architectural question... By default we don't have the set of protocols in place on the windows side of the conversation to talk to a unix.

This gets solved in different ways: Microsoft decided to use openpegasus.org for monitoring Unix systems as a mean to have a standardized WS-Man interface on those boxes, that acts similarly to what WMI does on Windows. I have a couple of posts where I have been experimenting with this http://www.muscetta.com/tag/wsman/ .

Another approach, as Steve already suggested, is to use PuTTy's SSH libraries - they are released under an open source license that allows you to embed their code in your - to call commands directly on the remote host.

With the WSMan/CIM daemon, the advantage is that you talk over a webservice and receive serialized objects you can consume (assuming you have built the right wrappers) - but it is not installed by default on unix boxes; SSH has the advantage to be installed by default on all modern unix dialects and with it you can do anything you would do at the unix command prompt natively (in fact, that's what you'd be doing) but you have to parse text you get back in the shell. There are also other implementations of SSH on windows, but I believe only PuTTY is free of charge and reusable. Other variants might come in already built libraries but you'd have to buy them separately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜