Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHMOD to an FTP site

Status
Not open for further replies.

cmhunt

Programmer
Joined
Apr 17, 2001
Messages
119
Location
GB
Hi

Using the FTP functions while connected to a remote UNIX server, I can CHMOD file called temp using the code:

$chmod_cmd="chmod 777 temp";
$chmod=ftp_site($conn_id, $chmod_cmd);

I would like to CHMOD all the files in the current directory.

Changing the command to "chmod 777 *" doesn't work as I get the error "Warning: ftp_site() [function.ftp-site]: *: No such file or directory" and the command doesn't complete.

If there is no way of doing this using the wildcard *, could someone please tell me if there is a way of looping through each file in the directory on the remote FTP server and processing the command??

If anyone has any better ways of doing the same thing, any input would be gratefully appreciated.

Thank you for your help.

Chris
 
Got it sorted with the code:

// chmod each entry
foreach ($contents as $entry) {
$filename=str_replace("/","",$entry);
$chmod_cmd="chmod 777 ".$filename;
$chmod=ftp_site($conn_id, $chmod_cmd);
}


Thanks

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top