public WriteLine ( string line ) : void | ||
line | string | The line to be written to the shell. |
리턴 | void |
static void Main(string[] args) { Console.WriteLine("fd"); try { ssh = new SshClient("10.141.3.110", "root", "ismail"); ssh.Connect(); //status = true; //timer_enable(); } //catch (Exception ex) // { // Console.Write(ex.Message); //} catch { } if (true) try { stream = ssh.CreateShellStream("xterm", 80, 50, 1024, 1024, 1024); Thread.Sleep(100); stream.WriteLine("telnet localhost 6571"); Thread.Sleep(100); } catch (Exception) { Console.WriteLine("hata"); } Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("fd"); try { ssh = new SshClient("10.141.3.110", "root", "ismail"); ssh.Connect(); //status = true; //timer_enable(); } //catch (Exception ex) // { // Console.Write(ex.Message); //} catch { } if (true) { try { stream = ssh.CreateShellStream("xterm", 80, 50, 1024, 1024, 1024); Thread.Sleep(100); stream.WriteLine("telnet localhost 6571"); Thread.Sleep(100); } catch (Exception) { Console.WriteLine("hata"); } } Console.ReadKey(); }
static void _main() { BlackCore.basic.cParams args = bcore.app.args; client = new System.Net.Sockets.TcpClient(); int wavInDevices = WaveIn.DeviceCount; int selWav = 0; for (int wavDevice = 0; wavDevice < wavInDevices; wavDevice++) { WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(wavDevice); Console.WriteLine("Device {0}: {1}, {2} channels", wavDevice, deviceInfo.ProductName, deviceInfo.Channels); } Console.Write("Select device: "); selWav = int.Parse(Console.ReadLine()); Console.WriteLine("Selected device is " + selWav.ToString()); sshClient = new SshClient(args["host"], args["user"], args["pass"]); sshClient.Connect(); if (sshClient.IsConnected) { shell = sshClient.CreateShellStream("xterm", 50, 50, 640, 480, 17640); Console.WriteLine("Open listening socket..."); shell.WriteLine("nc -l " + args["port"] + "|pacat --playback"); System.Threading.Thread.Sleep(2000); Console.WriteLine("Try to connect..."); client.Connect(args["host"], int.Parse(args["port"])); if (!client.Connected) return; upStream = client.GetStream(); //==================== WaveInEvent wavInStream = new WaveInEvent(); wavInStream.DataAvailable += new EventHandler<WaveInEventArgs>(wavInStream_DataAvailable); wavInStream.DeviceNumber = selWav; wavInStream.WaveFormat = new WaveFormat(44100, 16, 2); wavInStream.StartRecording(); Console.WriteLine("Working....."); Console.ReadKey(); sshClient.Disconnect(); client.Close(); wavInStream.StopRecording(); wavInStream.Dispose(); wavInStream = null; } }
public bool StartShellStream() { if (!ConnectSSH ()) return false; ManualResetEvent started = new ManualResetEvent(false); ShellStreamTask = new Task( () => { try { WriteLine("Starting terminal: Emulation = {0}",Host.TerminalEmulation); shellStream = sshClient.CreateShellStream(Host.TerminalEmulation,(uint)Host.TerminalCols,(uint)Host.TerminalRows,0,0,4096); shellStream.DataReceived += (object sender, ShellDataEventArgs e) => { Write(Encoding.UTF8.GetString(e.Data,0,e.Data.Length)); }; shellStream.ErrorOccurred+= (object sender, ExceptionEventArgs e) => { WriteLine(e.Exception.Message); keepShellAlive.Set(); }; if (!String.IsNullOrEmpty(Host.WorkingDir)) { Write("Changing dir: {0}...",Host.WorkingDir); shellStream.WriteLine(String.Format("cd {0}\r\n",Host.WorkingDir)); } started.Set(); keepShellAlive.Reset(); keepShellAlive.WaitOne(); WriteLine("\r\n*** Console Stream End"); } catch (Exception ex) { WriteLine("\r\n*** Console Stream Error: {0}",ex.Message); } finally { shellStream.Dispose(); shellStream = null; } }); ShellStreamTask.Start(); return started.WaitOne(5000); }
// // // // //int connect; //connect degiskeninini simdilik kullanmiyoruz.. //baglanma fonksiyonu tanimlamasi public void baglan() { ssh = new SshClient("10.141.3.110", "root", "ismail"); try { ssh = new SshClient("10.141.3.110", "root", "ismail"); ssh.Connect(); status = true; //connect = 1; } catch { status = false; tl.LogMessage("hata", "baglanti hatasi, tekrar deneyin.. [uc kapak getirene bardak hediye..]"); //connect = 0; } if(status==true) { try { stream = ssh.CreateShellStream("xterm", 80, 50, 1024, 1024, 1024); Thread.Sleep(100); stream.WriteLine("telnet localhost 6571"); Thread.Sleep(100); kontrol(); } catch { } } }
public SSHConnection(string host, string username) { this._host = host; this._username = username; _ssh = new SshClient(_host, _username, Passwords.FetchPassword(_host, _username)); _ssh.Connect(); _stream = _ssh.CreateShellStream("commands", 240, 200, 132, 80, 240 * 200); // Next job, wait until we get a command prompt _stream.WriteLine("# this is a test"); DumpTillFind(_stream, "# this is a test"); _prompt = _stream.ReadLine(); }
static void Main(string[] args) { client = new SshClient("130.18.14.67", "", ""); client.Connect(); stream = client.CreateShellStream(@"xterm", 80, 24, 800, 600, 2048); string cmd = ""; //flush buffer stream.Flush(); while(true) { stream.DataReceived += StartAsyncRead; Console.WriteLine("Logged in success!: "); cmd = Console.ReadLine(); stream.WriteLine(cmd); } }