note 27606 deleted from function.ftp-exec by vincent
| From: | vincent@php.net | Date: | Sun, 17 Aug 2003 13:54:37 +0000 |
| Subject: | note 27606 deleted from function.ftp-exec by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54533@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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($sR) {
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");
};
?>