note 27606 added to function.ftp-exec
| From: | php-general at lists dot php dot net | Date: | Thu, 12 Dec 2002 20:52:12 +0000 |
| Subject: | note 27606 added to function.ftp-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40807@lists.php.net to get a copy of this message | ||
Here is an example, check it out ;o) ...
<?PHP
$FTP_SERVER = 'myserver.tld';
$FTP_USER_NAME = 'myusername';
$FTP_USER_PASS = 'mypassword';
$FTP_COMMAND = 'ls -l';
// Try to connect
$fc = ftp_connect($FTP_SERVER);
if($fc) {
print("Connected to server $FTP_SERVER.\n");
// Login
if(! @ftp_login($fc, $FTP_USER_NAME, $FTP_USER_PASS)) {
print("Can't logged in as user $FTP_USER_NAME.\n");
exit;
} else {
print("Logged in as user $FTP_USER_NAME.\n");
};
// Exec command
print("\nOutput from executing '$FTP_COMMAND'\n\n");
$sR = nl2br(@ftp_exec($fc, $FTP_COMMAND));
if($R) {
print($sR);
} else {
print("There is no output from this command or it failed.\n");
};
// Close connection
ftp_quit($fc);
print("\nConnection closed.\n");
} else {
print("Can't connected to server $FTP_SERVER.\n");
};
?>
--
http://www.php.net/manual/en/function.ftp-exec.php
http://master.php.net/manage/user-notes.php?action=edit+27606
http://master.php.net/manage/user-notes.php?action=delete+27606
http://master.php.net/manage/user-notes.php?action=reject+27606