I want to control status of my Tomcat server from ASP.NET. So basically I execute the following commands:
sudo /etc/rc.d/init.d/tomcat5_3 status
sudo /etc/rc.d/init.d/tomcat5_3 stop
sudo /etc/rc.d/init.d/tomcat5_3 start
I use a simple call of method Session.ExecuteCommand
from WinSCP .NET assembly like below:
public string ExecScript(string cmd)
{
try
{
CommandExecutionResult result = sessDB.ExecuteCommand(cmd);
result.Check();
return result.Output;
}
catch (Exception e)
{
Console.WriteLine("An error occurred: '{0}'", e);
}
return "";
}
I call ExecScript
with one of these three commands:
string result = ExecScript("sudo /etc/rc.d/init.d/tomcat5_3 status");
The status command works fine. Always return a string so I am able to parse it and get a correct status of Tomcat.
But when I try to stop/start result should be something like below:
1st message
Stopping tomcat:
2nd part of message after a few seconds
Stopping tomcat: [OK]
and then problem appears. Program of course does not show these messages, it just hangs, output window returns code 259 which as I know means "command still in progress".
In fact stop/start operation finishes with success. But my app does not inform me about it. No error, no exception, hung ...
Any hints, advices?