00001 using System;
00002 using System.Collections;
00003 using Tamir.SharpSsh;
00004 using System.IO;
00005
00006 namespace sharpSshTest.sharpssh_samples
00007 {
00011 public class SshShellTest
00012 {
00013 public static void RunExample()
00014 {
00015 try
00016 {
00017 SshConnectionInfo input = Util.GetInput();
00018 SshShell shell = new SshShell(input.Host, input.User);
00019 if(input.Pass != null) shell.Password = input.Pass;
00020 if(input.IdentityFile != null) shell.AddIdentityFile( input.IdentityFile );
00021
00022
00023 shell.RedirectToConsole();
00024
00025 Console.Write("Connecting...");
00026 shell.Connect();
00027 Console.WriteLine("OK");
00028
00029 while(shell.ShellOpened)
00030 {
00031 System.Threading.Thread.Sleep(500);
00032 }
00033 Console.Write("Disconnecting...");
00034 shell.Close();
00035 Console.WriteLine("OK");
00036 }
00037 catch(Exception e)
00038 {
00039 Console.WriteLine(e.Message);
00040 }
00041 }
00042 }
00043 }