Inconsistent SSH behavior - WeOnlyDo Discussion board

Inconsistent SSH behavior (General questions)

by Herut, Thursday, April 22, 2010, 17:28 (5328 days ago)

Hi,

I am trying to run background process and get his process ID.
Part of the time my code is working well, and part of the time I can't get the process ID.

Here is my code:
[code]
public string Execute(string command)
{
if (sshConnect.State != SSH.States.Connected)
return Not Connected ;

answer = sshConnect.Execute(command +
);
return answer;
}

public int BackgroundProcess(string command, ref string pAnswer)
{
Execute(command + & );

pAnswer = answer;
string[] lines = answer.Split(new string[] {
}, StringSplitOptions.None);
foreach (string line in lines)
{
if (line.StartsWith( [ ) && line.Contains( ))
return Convert.ToInt32(line.Substring(line.IndexOf( ))); // returns process ID
}

// process ID yet didn't find - no process ID
return 0;
}
[/code]

Too many times the process is running, but I can't get his process ID.

Can you help please? Should I use other SSH functions?

Thanks.


Complete thread: