Question

I want to remotely execute commands on a machine from a host machine executing say a C#/C++/C type of application. The application is intended to control and execute the execution of commands on the remote machine. Is it possible to something like this by any means using any programming language??

I have checked about psexec etc, but I want more control, therefore thinking of doing it programatically "my way" :)

Regards Anand

Was it helpful?

Solution

Not sure about the type of commands you are looking for. Simply "invoke-command" should be able execute commands on local and remote computers.

If you are looking for customization to a great extend, you might need to develop agents (such as build agents used with CI) that can execute.

OTHER TIPS

Googlr for "Remote Procedure Call" and look at http://en.wikipedia.org/wiki/SOAP

for Unix ssh is good option, for Windows you can use winrm / powershell combination, there are c++ api's available for winrm/powershell.

psexec is good way to explore. look here for more details.

In C# it's pretty trivial to host a WCF service in your app and remote that way.

Check out this link.

I've used xml-rpc before for RPC in C and that's pretty straightforward.

It really depends on what type of "commands" you want to run, how beefy you want your app(s) to be, and what sort of resources (time, cost, labor, skill-level, etc.) you have available. You have a lot of options, from the banal and easily-implemented, to the over-architected, SOA masterpiece. As mentioned above, you can use something straightforward like SSH, PowerShell, etc., but it sounds like you want something more powerful (modern?) (BTW, xml-rpc isn't all unicorns and rainbows; I have the scars to prove it!)

Sending remote commands between machines is an old, solved problem, so there's a lot of existing tech you can take advantage of: RPC -> XML-RPC -> WS-*/SOAP -> SOAP-RPC -> .Net Remoting -> WCF -> REST... and those are just a select few you have access to.

If your requirements are pretty simple, I would shy away from a full-blown SOA/ESB-type architecture, and perhaps use a technology like WCF (which can still be used if you dream big, and want to expand the app into an SOA masterpiece later on). There's a bit of a learning curve with WCF (and WCF certainly isn't all unicorns and rainbows either), but there are a lot of resources our there to learn from.

Using WCF, you can also implement the actual calls via REST, encode the data in JSON, build the whole thing in an ASP.Net MVC application, and then you will be fully buzzword-compliant. More importantly though, you'll have an application that is flexible and expandable in the future.

It would help to know more about the exact types of commands you want to run, and the functionality you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top