PHP 8.3.4 Released!

ftp_exec

(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)

ftp_execFordert die Ausführung eines Programmes auf dem FTP-Server an

Beschreibung

ftp_exec(FTP\Connection $ftp, string $command): bool

Sendet ein SITE EXEC-Kommando (command) an den FTP-Server.

Parameter-Liste

ftp

Eine FTP\Connection-Instanz.

command

Das auszuführende Kommando.

Rückgabewerte

Gibt true zurück, wenn das Kommando erfolgreich war (d. h. der Server hat den Antwortcode 200 gesendet), sonst false.

Changelog

Version Beschreibung
8.1.0 Der Parameter ftp erwartet nun eine FTP\Connection-Instanz; vorher wurde eine Ressource erwartet.

Beispiele

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);

?>

Siehe auch

  • ftp_raw() - Sendet ein beliebiges Kommando an den FTP-Server

add a note

User Contributed Notes 1 note

up
-1
sam at totallydigital dot co dot nz
20 years ago
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.
To Top