For example:
How do I instantiate a shell?
Using the following code, why does "ls" work but "cd [to some folder]" doesn't?
How do I display the typical *nix prompt? (For example, I'm connecting to a BeagleBone Black with Debian installed, so no, I don't care if you see Debian's default username and password in the code below.)
This looks like a great library, and I wouldn't mind actually writing a Code Project article or two showing how to use it, but I'm stuck on some very basic stuff!
Thanks in advance,
Marc Clifton
Here's my test code (taken from another post here):
How do I instantiate a shell?
Using the following code, why does "ls" work but "cd [to some folder]" doesn't?
How do I display the typical *nix prompt? (For example, I'm connecting to a BeagleBone Black with Debian installed, so no, I don't care if you see Debian's default username and password in the code below.)
This looks like a great library, and I wouldn't mind actually writing a Code Project article or two showing how to use it, but I'm stuck on some very basic stuff!
Thanks in advance,
Marc Clifton
Here's my test code (taken from another post here):
class Program
{
static void Main(string[] args)
{
PasswordAuthenticationMethod authMethod = new PasswordAuthenticationMethod("debian", "temppwd");
ConnectionInfo connectionInfo = new ConnectionInfo("192.168.1.42", "debian", authMethod);
using (var ssh = new SshClient(connectionInfo))
{
ssh.Connect();
while (true)
{
string line = Console.ReadLine();
if (String.IsNullOrEmpty(line))
{
continue;
}
var cmd = ssh.CreateCommand(line); // very long list
var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
{
// Console.WriteLine("Finished.");
}, null);
var reader = new StreamReader(cmd.OutputStream);
while (!asynch.IsCompleted)
{
string result = reader.ReadLine();
if (!String.IsNullOrEmpty(result))
{
Console.WriteLine(result);
}
}
cmd.EndExecute(asynch);
}
}
}
}