0

PSCP.EXE (Putty) を使用して外部 Linux サーバーからローカル サーバーにファイルをコピーするコマンド ライン プロセスを実行する ASP.NET アプリケーションで実行されているコードがあります。Visual Studio 2010 で Run コマンドを使用して ASP.NET アプリケーションを対話的に実行すると、正常に動作します。しかし、アプリケーションを (同じサーバー上の) IIS にデプロイして実行しようとすると、PSCP.EXE コマンド ラインからエラーが返されます。エラーは次のとおりです。

致命的: ネットワーク エラー: 接続がタイムアウトしました

私はその PSCP.EXE エラーについて少し調査しましたが、ポートを指定する必要があることを示唆する人々だけが見つかりました。しかし、Visual Studio でアプリを実行すると問題なく動作するので、私には当てはまらないと思います。

私のボックスでIIS 7からコマンドを実行すると接続タイムアウトエラーが発生する理由を知っている人はいますが、同じボックスでVisual Studioを介して実行すると正常に動作しますか?

これが私のコードです:

string _pscpExePath = ConfigurationManager.AppSettings["PSCPExePath"];
string _localOptionsFolder = ConfigurationManager.AppSettings["LocalOptionsFileFolder"];
string _remoteOptionsLocation = ConfigurationManager.AppSettings["RemoteOptionsFileLocation"];

ProcessStartInfo _procStartInfo = new ProcessStartInfo("cmd", "/c " + _pscpExePath + " -pw " + App.ConfigData.ModemAdminPassword + " root@" + App.ConfigData.ModemIPAddress + ":" + _remoteOptionsLocation + " " + _localOptionsFolder);
_procStartInfo.RedirectStandardOutput = true;
_procStartInfo.RedirectStandardError = true;
_procStartInfo.UseShellExecute = false;
_procStartInfo.CreateNoWindow = true;

using (Process _proc = Process.Start(_procStartInfo))
{
  using (StreamReader _reader = _proc.StandardOutput)
  {
    string _result = _reader.ReadToEnd();
    log.Info("Get Options File Result = " + _result);
  }

  using (StreamReader _error = _proc.StandardError)
  {
    string _result = _error.ReadToEnd();
    log.Info("Get Options File Error = " + _result);
  }
}
4

1 に答える 1

0

私が間違っていたようです。IIS サイトが Linux サーバーに接続できない別の理由がありました。現在、すべてが正常に機能しています。この質問は回答済みとしてマークすることができ、実際にはコードなどの問題ではないため、削除することもできます.

于 2012-12-13T00:17:02.840 に答える