
ssh2_exec 함수의 error_level 매개변수를 설정하는 방법은 다음과 같습니다.
#hostingforum.kr
php
$connection = ssh2_connect('호스트 이름', 22);
ssh2_auth_password($connection, '사용자 이름', '비밀번호');
$result = ssh2_exec($connection, '명령어', array('error_output' => SSH2_STREAM_STDIO));
if (!ssh2_exec($connection, '명령어', array('error_output' => SSH2_STREAM_STDERR))) {
echo "에러 발생";
} else {
echo "성공";
}
error_level 매개변수를 설정하여 에러 메시지를 출력하는 방법은 다음과 같습니다.
#hostingforum.kr
php
$connection = ssh2_connect('호스트 이름', 22);
ssh2_auth_password($connection, '사용자 이름', '비밀번호');
$result = ssh2_exec($connection, '명령어', array('error_output' => SSH2_STREAM_STDIO));
if ($error = ssh2_fetch_stream($result, SSH2_STREAM_STDERR)) {
echo "에러 발생: " . stream_get_contents($error);
} else {
echo "성공";
}
이러한 방법을 통해 ssh2_exec 함수의 에러 메시지를 출력할 수 있습니다.
2025-04-08 20:52