I have a relatively simple scenario. I need to telnet into a UNIX server. Issue a command. And receive all the output from said command.
I used the below function to log on, issue a simple command, get its output, then issue my more complicated command, and retrieve its output.
The Problem:
Not all the output is returned from "myunixcommand '/my path to file/for param for command'"
. I get the last 19 lines of output, instead of the 70 some lines of actual output. There are a couple crlf (0d0a) in the output, im not sure if thats the issue?
I tried two methods to retrieving all the output, both return the same thing.
Any ideas?
public static void test4(string server, string un, string pw)
{
Telnet client = new Telnet(server);
Shell shell = client.StartShell();
shell.Prompt = "$ ";
string response = shell.ReadAll("ogin: ");
shell.SendCommand(un);
response = shell.ReadAll("ssword: ");
shell.SendCommand(pw, true);
string loginMessage = shell.ReadAll();
//send some easy command i know will work
shell.SendCommand("echo test");
loginMessage = shell.ReadAll();
//try a command with lots of output
shell.SendCommand("myunixcommand '/my path to file/for param for command'", true);
//Try #1
//loginMessage = "";
//while (shell.IsRunning)
//{
// loginMessage += result;
//}
//Try #2
loginMessage = shell.ReadAll();
// close the shell
shell.Close();
}