2
scp 명령을 실행하고 일부 파일을 제공하는 PHP 스크립트를 만들려고합니다. 문제는 명령에 "예/아니오"라는 질문과 암호가 필요하다는 것입니다. 스크립트에서 전달하는 방법을 알 수 없습니다.PHP proc_open 함수에 대한 답변을 전달하는 방법은 무엇입니까?
내 코드 :
$command = "scp $filename {$config['Username']}@{$config['Server']}:{$config['Basedir']}";
echo $command;
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", sys_get_temp_dir() . "/error.txt", "w"), // stderr is a file to write to
);
$cwd = sys_get_temp_dir();
$env = array();
$process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
fwrite($pipes[0], "yes\n");
fwrite($pipes[0], $config['Password'] . "\n");
proc_close($process);
이 작동하지 않습니다. 스크립트에서 "계속 연결 하시겠습니까 (예/아니오)?")라는 질문을받습니다. 때마다.