array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'function.ftp-exec.php', 1 => 'ftp_exec', ), 'up' => array ( 0 => 'ref.ftp.php', 1 => 'FTP-Funktionen', ), 'prev' => array ( 0 => 'function.ftp-delete.php', 1 => 'ftp_delete', ), 'next' => array ( 0 => 'function.ftp-fget.php', 1 => 'ftp_fget', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'de', 'path' => 'reference/ftp/functions/ftp-exec.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)
ftp_exec — Fordert die Ausführung eines Programmes auf dem FTP-Server an
Sendet ein SITE EXEC-Kommando (command
) an den
FTP-Server.
Gibt true
zurück, wenn das Kommando erfolgreich war (d. h. der Server hat
den Antwortcode 200
gesendet), sonst false
.
Version | Beschreibung |
---|---|
8.1.0 |
Der Parameter ftp erwartet nun eine
FTP\Connection-Instanz; vorher wurde eine Ressource
erwartet.
|
Beispiel #1 ftp_exec()-Beispiel
<?php
// Variable initialisieren
$command = 'ls -al >files.txt';
// Verbindung aufbauen
$ftp = ftp_connect($ftp_server);
// Login mit Benutzername und Passwort
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// Kommando ausführen
if (ftp_exec($ftp, $command)) {
echo "$command wurde erfolgreich ausgeführt\n";
} else {
echo "$command konnte nicht ausgeführt werden\n";
}
// Verbindung schließen
ftp_close($ftp);
?>