Jump to content

Looping ftp_connect (Works on 1st connection not the rest)


alwoodman

Recommended Posts

Im trying to change permissions on files on multiple ftp connections I have a database of file names that i want to change and a list of domains to step through with the corresponding connection details (their all on the same server). Its processing the first connections files perfectly but when it comes to the next step in the loop (and the rest) its saying

 

Warning: ftp_chmod() [function.ftp-chmod]: User myusername logged in in /var/www...

 

above where it says User myusername logged in, it is the right username but is it somehow referencing the previous session somewhere?

 

here's the code

 


do { 

$ftp_server = "1.1.1.1";
$ftp_user = $row_get['ftp_username'];
$ftp_pass = $row_get['ftp_password'];

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

	// try to login
	if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
		echo "Connected as $ftp_user@$ftp_server\n";

	do {
			$newch = '0'.$row_getFiles['file_chmod'];

			if (ftp_chmod($conn_id, eval("return({$newch});"), $row_getFiles['file_name']) !== false) {
			echo "CHMOD successfull on ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>";
			} else {
			echo "Could not CHMOD ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>";
			}

	}while ($row_getFiles = mysql_fetch_assoc($getFiles));

	} else {
		echo "Couldn't connect as $ftp_user\n";
	}

	ftp_close($conn_id);					

	echo "<b>- - - - - - - - - - - - -</b><br/>";							

}while ($row_get= mysql_fetch_assoc($get));

}
?>

Thanks Wolfrage, i added sleep(15); after the ftp_close but its still having the same problem...

 

	// try to login
	if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
		echo "Connected as $ftp_user@$ftp_server\n";		

				do {
						$newch = '0'.$row_getFiles['file_chmod'];

						if (ftp_chmod($conn_id, eval("return({$newch});"), $row_getFiles['file_name']) !== false) {
						echo "CHMOD successfull on ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>";
						} else {
						echo "Could not CHMOD ".$row_getFiles['file_name']." to ".$row_getFiles['file_chmod']."<br/>";
						}

				}while ($row_getFiles = mysql_fetch_assoc($getFiles));

		ftp_close($conn_id);
		sleep(15);

 

 

regards

 

Lee

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.