php - SFTP remove files with wildcard characters -
i tried use phpseclib delete logs in sftp server.
codes simple:
$sftp = new net_sftp($host_name); $sftp->login($username, $password); // login successful $sftp->chdir('/somefolder'); if(!$sftp->delete('*.log')) { $logger->error('cannot remove logs'); }
the log shows "cannot remove logs".
however, use sftp command in shell, works :
$ sftp myusername@example.com password: (type in password) sftp> cd /somefolder sftp> rm *.log removing xxx.log removing yyy.log sftp> ls ( no more *.log ) sftp> exit
does phpseclib delete function supports wildcard character ? if not, alternatives ?
does phpseclib delete function supports wildcard character ? if not, alternatives ?
not @ present no. guess $sftp->nlist()
, preg_match on each row returned nlist. if matches delete it, otherwise keep it.
Comments
Post a Comment