Gossamer Forum
Quote Reply
CHMOD
Hi:

I've just moved a number of files to a new directory. Problem is that the files are CHMOD 0644 whereas they need to be 0666. I could FTP and CHMOD them file by file but there are over 300 files to do!

To that end, I created the following script to do the job:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<html>\n\n";

print "CHMODing Backup Files... ";
opendir (DATA, "/home/serve/topsite/scripts/top50/backup/");
@filenames = grep (!/^\.\.?$/, readdir (DATA));
closedir (DATA);
foreach $i (@filenames) {
chmod(0666, "/home/serve/topsite/scripts/top50/backup/$i");
}
print "Complete.<p>\n\n";
exit;

The script executes flawlessly but upon inspection, the files are still 0644.

Huh?

Dan Smile
Quote Reply
Re: CHMOD In reply to
Well, this might help:

Quote:
chmod(0666, "/home/serve/topsite/scripts/top50/backup/$i") or die "Can't chmod file $i. Reason: $!";

Always check your return value to see if the function was ok!

Cheers,

Alex
Quote Reply
Re: CHMOD In reply to
Silly me! Thanks Alex!

After running the script with the modification, the error message is "Operation not permitted."

Huh again? This is the only time I've had problems CHMODing with a script. I tried via FTP and no problems.

Dan Smile
BTW, hi from Vancouver!
Quote Reply
Re: CHMOD In reply to
But are you running your application from the web or from telent. If you can do it frmo ftp, you should be able to do it from telnet too, since both would assign the ownership to your user id.

If you try from the web, that could be the problem, as web runs as user Nobody.

--mark

------------------
You can reach my by ICQ at UID# 8602162

Quote Reply
Re: CHMOD In reply to
Hi Mark:

I'm not running the script from FTP but rather using the FTP CHMOD function. But this has to be done file by file as you cannot select a range of files to CHMOD.

But I believe you nailed it on the head. I cannot run the script as nobody from the web. I suspected this may be the culprit. Can WS_FTP be used to run a external program / script? BTW, I don't have telnet access - I did originally but I persuaded the server to remove root access from users as I didn't like the security aspect of users being able to access other users' directories.

Dan Smile