GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   chmod -R 755 *.cgi (https://gfy.com/showthread.php?t=79191)

HQ 09-26-2002 06:58 AM

chmod -R 755 *.cgi
 
Why does this command NOT work?

chmod -R 755 *.cgi
chmod: getting attributes of `*.cgi': No such file or directory

I want to recursively change every .cgi file to 755. Is there no way to do a wildcard and recurse at the same time with chmod?

Vendot 09-26-2002 07:03 AM

Looks like you need to recurse and wildcard before you chmod the .attribute.

If you chmod the 755 back to 745 it will also.

HQ 09-26-2002 07:05 AM

You mean like this?

chmod -R *.cgi 755
chmod: invalid mode string: `*.cgi'

gallerypost 09-26-2002 07:36 AM

Quote:

Originally posted by HQ
Why does this command NOT work?

chmod -R 755 *.cgi
chmod: getting attributes of `*.cgi': No such file or directory

I want to recursively change every .cgi file to 755. Is there no way to do a wildcard and recurse at the same time with chmod?

bah... well the thing is that when you give it *.cgi it'll search only for *.cgi files for the chmod...
directories aren't *.cgi so the -R won't help, it won't get into the directories....

that's why it didn't work, but i don't know what should work, i almost have no clue about *nix .... so if you find the answer... please share it with us ;)

HQ 09-26-2002 07:38 AM

I think you are right. How do I tell it to recurse a directory (the current directory) and apply the *.cgi wildcard at the same time?

boldy 09-26-2002 07:43 AM

.

HQ 09-26-2002 07:46 AM

Quote:

Originally posted by boldy
.
I know that. How do I do both though?

HQ 09-26-2002 07:48 AM

[edit]

I was wrong. This command does NOT work.:

chmod -R 755 . *.cgi

It changes ALL files. Same as running this command:

chmod -R 755 .

boldy 09-26-2002 07:59 AM

Told u

.

:thumbsup

HQ 09-26-2002 08:23 AM

Nope, I was wrong. That above command CHANGES ALL FILES just as running "chmod -R 755 ." would do.

FUCK! :feels-hot

HQ 09-26-2002 08:26 AM

Anyone know how to do this? If it can not be done, I am going to have to code a script to do this because I have way too many files to manually change.

FuqALot 09-26-2002 08:59 AM

Hi,

cd to the directory and type:
find -name '*.cgi' -exec chmod 755 {} \;

Hope this helps.

salsbury 09-26-2002 09:07 AM

to summarize, keep this in mind.

your shell is what does the wildcard expansion. so when you type:

chmod -R 755 *.cgi

your shell expands *.cgi to a list of the files in the current directory that end with .cgi . this would also include directories (which are basically files) that happened to be named something.cgi . only after the expansion is done are the arguments actually sent to chmod.

some shells will error out if there are no .cgi files. other shells (better shells) wil just pass '*.cgi' on to the chmod binary. chmod doesn't understand wildcards (most binaries don't, find is an exception) so it would try to change the permissions on a file called '*.cgi'. if that file was a directory it would change them recursively.

fuqalot's post is correct. i'm just clarifying why this happens.

HQ 09-26-2002 09:35 AM

Thanks for explaining how it works salsbury, that helps a lot. So wildcards and recursing are exclusive, which is what I thought, I just did not know exactly why.

HQ 09-26-2002 10:04 AM

Quote:

Originally posted by FuqALot
cd to the directory and type:
find -name '*.cgi' -exec chmod 755 {} \;

Oh... and thanks a million, FuqALot, it works.

BTW, the "{}" is the list of files that find returns, right? What is the "\" for?

FuqALot 09-26-2002 10:26 AM

Quote:

Originally posted by HQ


Oh... and thanks a million, FuqALot, it works.

BTW, the "{}" is the list of files that find returns, right?

Yep.

Quote:


What is the "\" for?

The \; just terminates the command (-exec option), so it 'tells' the -exec line has ended.

HQ 09-26-2002 10:52 AM

Excellent. Thanks again.


All times are GMT -7. The time now is 10:27 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123