tags:

views:

430

answers:

2

We have soap services running on our unix box (local network with AFS). Sometimes our services are down and our front end developers, due to lack of knowledge of unix find it difficult to restart the services. Is it possible to build a UI(C#-winforms) which will login to the Unix box and run scripts which starts the service/runs a command to check if services are running on a particular port and capture the output.

A: 

See the System.Diagnostics.Process class:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

Once a Process instance is created and running, the .StandardOutput property will contain a StreamReader that can be used to read the output of the executing process.

Amber
Are you sure this can used to capture output of a process running on a unix box?
P.K
You will need some way of connecting to the unix box in the first place, which probably implies some form of ssh connection. If you have a script you can execute on the machine which is running the C# application to do the SSH login and execute the scripts on the UNIX machine, then the locally-running script should echo the output from the remote scripts, and then C# can capture the locally echo'd output. Otherwise, you're looking at attempting to find an implementation of the SSH protocol for C#, like this one: http://www.tamirgal.com/blog/page/SharpSSH.aspx
Amber
yes this using SharpSSH is the only way out I guess
P.K
+1  A: 

Such tasks can be done using ssh, that allows executing commands remotely.

All you need is ssh client (putty, cygwin) and execute it from simple bat file.

See: http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html, plink is part of putty.

Artyom
You'd be looking specifically at this section: http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html#plink-usage-batch
Matthew Scharley