varien_io_sftp의 RM ($ Filename) 메서드가 원격 파일을 삭제하지 않습니다.
문제
나는 Magento dev에 꽤 새로운 것이므로 내 용어 중 일부가 옳지 않다면 나를 용서해주십시오.
My Module은 SFTP 프로토콜을 사용하여 원격 FTP 서버에서 XML 파일을 다운로드하고 삭제해야합니다.나는 그를 위해 varien_io_sftp 클래스를 사용하고 있습니다.
연결을 열고, 필요한 디렉토리로 변경하고 파일을 검색 할 수 있지만 varien_io_sftp rm 메소드를 사용하여 삭제하려고하면 원격 파일이 삭제되지 않습니다.
<?php
$vcXMLOut = "/XML/export";
$filename = "test.txt"
$sftpGetFiles = new Varien_Io_Sftp();
$sftpGetFiles->open(
array(
'host' => "ftp.test.com",
'username' => "test",
'password' => "test",
'timeout' => '100'
)
);
$sftpGetFiles->cd($vcXMLOut);
$file = $sftpGetFiles->read($filename); //Contents of file are read successfully
$sftpGetFiles->rm($filename); //File remains
.
파일의 사용 권한 문제를 해결했습니다.
나는 왜 내가 오류가 있는지 확신하지 못한다.이 코드가 CRON 일정에서 실행되고 있기 때문입니까?데이터베이스는 예정된 작업이 성공적이었습니다.모든 로그에서 찾을 수있는 것은 없습니다.
내가 뭘 잘못하고 있는지 아이디어?누구나이 코드를 더 잘 디버그 할 수있는 방법에 대한 아이디어가 있습니까?
해결책
일부를 중심으로 한 후에는 읽기 메서드가 현재 디렉토리와 관련된 파일 이름을 수락하는 동안 RM 메서드가 포함 된 경로가 필요합니다.다음 코드는 나를 위해 작동합니다.
<?php
$vcXMLOut = "/XML/export";
$filename = "test.txt"
$sftpGetFiles = new Varien_Io_Sftp();
$sftpGetFiles->open(
array(
'host' => "ftp.test.com",
'username' => "test",
'password' => "test",
'timeout' => '100'
)
);
$sftpGetFiles->cd($vcXMLOut);
$file = $sftpGetFiles->read($filename); //Contents of file are read successfully
$sftpGetFiles->rm($sftpGetFiles->pwd().$filename); //File is successfully deleted
. 제휴하지 않습니다 magento.stackexchange