A word of caution, execution via FTP isn't very widely supported. Check that it works on the servers that you intend to connect to before you start coding something that requires this.
(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)
ftp_exec — FTP sunucusunda bir komut çalıştırma isteği yapar
$ftp
, string $komut
): bool
FTP sunucusuna belirtilen SITE EXEC komut
u için
istek gönderir.
ftp
FTP bağlantısının bağlantı tanıtıcısı.
komut
Çalıştırılacak komut.
İşlem başarılı olursa (sunucu yanıt kodu 200
ise) true
olmazsa false
döner.
Örnek 1 - ftp_exec() örneği
<?php
// değişken ilklendirmesi
$komut = 'ls -al >files.txt';
// temel bağlantıyı kuralım
$conn_id = ftp_connect($ftp_server);
// Kullanıcı adı ve parola ile oturum açalım
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// komutu çalıştıralım
if (ftp_exec($conn_id, $komut)) {
echo "$komut sorunsuzca çalıştırıldı\n";
} else {
echo "$komut çalıştırılamadı\n";
}
// bağlantıyı kapatalım
ftp_close($conn_id);
?>
A word of caution, execution via FTP isn't very widely supported. Check that it works on the servers that you intend to connect to before you start coding something that requires this.