2014-10-17 2 views
0

나는 SSH2-> read() 메소드의 출력을 포맷하려하고있다. 나는 http://phpseclib.sourceforge.net/ssh/examples.html#topPHP SSH2 read() 출력을 포맷하는 방법은 무엇입니까?

내 코드 다음 ANSI.php를 사용하여 시도

<?php 
include('Net/SSH2.php'); 
include('File/ANSI.php'); 
$ssh = new Net_SSH2('10.106.240.212'); 
$ssh->login('Administrator', 'Nbv12345') or die("Login failed"); 
$ansi = new File_ANSI(); 

$ssh->enablePTY(); 
$ssh->exec("powershell.exe\n"); 
$ssh->setTimeout(2); 
echo $ssh->read(); 
$ssh->write("ls\n"); 
echo $ssh->read(); 
?> 

출력은 ANSI 문자로 가득하다없이 '1!'결과는

(B)0[?7l[H[J[1;1HWindows PowerShell[2;1HCopyright (C) 2013 Microsoft Corporation. All rights reserved.[4;1HPS C:\Users\Administrator> (B)0[?7l[H[J[1;1H [2;1H [3;1H [4;1H [5;1H [6;1H [7;1H [8;1H [9;1H [10;1H [11;1H [12;1H [13;1H [14;1H [15;1H [16;1H [17;1H [18;1H [19;1H [20;1H [21;1H [22;1H [23;1H [24;1H [1;1HMicrosoft Windows [Version 6.3.9600][2;1H(c) 2013 Microsoft Corporation. All rights reserved.[4;1HC:\Users\Administrator>ls[5;1H 

내가 아니고 이런 식으로 뭔가가 필요 심지어 가까운 것 : enter image description here

어떻게 포맷 할 수 있습니까?

답변

0

클래스를 초기화한다고해서 LOL을 포함한다는 의미는 아닙니다. 시도해보십시오.

<?php 
include('Net/SSH2.php'); 
include('File/ANSI.php'); 
$ssh = new Net_SSH2('10.106.240.212'); 
$ssh->login('Administrator', 'Nbv12345') or die("Login failed"); 
$ansi = new File_ANSI(); 

$ssh->enablePTY(); 
$ssh->exec("powershell.exe\n"); 
$ssh->setTimeout(2); 
$ansi->appendString($ssh->read()); 
$ssh->write("ls\n"); 
$ansi->appendString($ssh->read()); 
echo $ansi->getScreen(); 
?> 

예. 전화 번호 $ssh->read()을 모두 $ansi->appendString()으로 바꾼 다음 $ansi->getScreen()으로 보내십시오. 또는 $ssh->write("ls\n") 이후에 $ssh->read()$ansi->appendString()에 감쌀 수도 있습니다. $ansi->getHistory()도 할 수 있습니다.

+0

안녕하세요, Neubert, 이미 시도했습니다. ANSI.php는 (B와) 0과 같은 몇 개의 문자를 구문 분석 할 수 없으며 출력은 프롬프트입니다. 다른 건 없어! '(B는 C : \ Wamp \ www \ PT_TEST_FRAMEWORK \ php \ phpseclib \ File \ ANSI.php 434 번 라인에서 지원되지 않음' –

+0

File_ANSI를 통해 실행하기 전에 전체 출력을 pastebin .com 링크? – neubert

관련 문제