2011-12-21 10 views
1

sshを介して2つの異なるTandbergユニットと同時にやり取りするWindowsマシン(Windowsマシンでは他のWindows-yものを実行しているため)にアプリケーションを作成する必要があります。コンソールログストリームを監視し、特定のイベントに反応します。変数にいくつかの情報を格納し、これらの2つの異なるsshセッションを比較する必要があります。あるいは、私はちょっとしたsecurecrtスクリプトを使うだけです。WindowsマシンからSSHセッションと対話する最も簡単な方法は?

私はそれをphp(cli)で簡単に動作させることができました。これは私が知っている1つの言語ですが、このプロジェクトにとっては明らかに理想的ではありません。私は新しい言語を見つけ出すことで自分のやり方をハックすることにかなり慣れています.net/c#でおそらくできると思います - 誰もが数百ドルのコストがかからないssh .netライブラリを持っていますか?私はこれを達成するための他の提案にも開放しています。

+0

http://stackoverflow.com/q/8516284/293712 – Maheep

+0

http://stackoverflow.com/questions/530330/sftp-libraries-for-net – vittore

答えて

0

PHPでは、SSHv2のライブラリを使用することができます。http://php.net/manual/en/book.ssh2.php

コンソール使用ssh2_fetch_streamを読むにしてコマンドをssh2_execを使用し実行します。

1

私は正常にplink.exeを使用してLinuxにコマンドを送信し、それらのコマンドからテキストベースの検索結果を取得しました。私も、このためにPLINKを使用しました

public string ExecuteCmd() 
    { 
     try 
     { 
      string strReturn = ""; 
      string param = ""; 
      StreamReader standerOut; 

      Process p = new Process(); 
      p.StartInfo.FileName = @"plink.exe"; 

      if (this.pass.Length == 0 || this.user.Length == 0 || this.host.Length == 0 || this.cmd.Length == 0) 
      { 
       throw new Exception("SSHClient: Invalid parameteres for SSHClient."); 
      } 

      param = "-ssh -pw " + this.pass + " " + this.user + "@" + this.host + " " + this.cmd; 

      string cd = Environment.CurrentDirectory; 

      if (File.Exists("plink.exe") == false) 
      { 
       throw new Exception("SSHClient: plink.exe not found. Make sure plink.exe is in the same folder as YOUR EXE."); 
      } 
      else 
      { 
       p.StartInfo.UseShellExecute = false; 
       p.StartInfo.RedirectStandardInput = true; 
       p.StartInfo.RedirectStandardOutput = true; 
       p.StartInfo.RedirectStandardError = true; 
       p.StartInfo.CreateNoWindow = true; 
       p.StartInfo.Arguments = param; 

       p.Start(); 
       standerOut = p.StandardOutput; 

       while (!p.HasExited) 
       { 
        if (!standerOut.EndOfStream) 
        { 
         strReturn += standerOut.ReadLine() + Environment.NewLine; 
         //textBox2.SelectionStart = textBox1.Text.Length; 
         //textBox2.ScrollToCaret(); 
        } 

        // Application.DoEvents(); 
       }      
      } 

      return strReturn; 
     } 
     catch (Exception exp) 
     { 
      throw new Exception("SSHClient:", exp); 
     } 
    } 
1

が、あなたは別のプロセスを起動することを避ける必要がある場合は、SSH.NETしてみてください:http://sshnet.codeplex.com/

後は、あなたが望むすべてです。

関連する問題