client.Connect();
var shell = client.CreateShellStream("test", 80, 24, 800, 600, 1024);
var input = "cd /nonexistant";
shell.DataReceived += (sender, args) => Console.Write(client.ConnectionInfo.Encoding.GetString(args.Data));
shell.Expect(new Regex(@"\$ $")); // CMD prompt
shell.WriteLine(input);
=>Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-44-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Mon Feb 2 13:07:03 CET 2015
Last login: Mon Feb 2 13:07:03 2015 from xxx.xxx.xxx.xxx
~$ cd /nonexistant
-bash: cd: /nonexistant: No such file or directory
~$
Maybe your Regex is wrong or your Thread.Sleep(200) (which is basically just guessing by you)?Why don't you use RunCommand instead of guessing and trying to find the command prompt:
var cmd = client.RunCommand("cd /nonexistant");
Console.WriteLine("STDERR: " + cmd.Error);
Console.WriteLine("ERRORCODE: " + cmd.ExitStatus);
Console.WriteLine("STDOUT: " + cmd.Result);