note 27606 modified in function.ftp-exec by didou
| From: | didou@php.net | Date: | Wed, 04 Jun 2003 09:20:52 +0000 |
| Subject: | note 27606 modified in function.ftp-exec by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-49698@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($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");
};
?>
--was--
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