Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-26-2002, 06:58 AM   #1
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
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?
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:03 AM   #2
Vendot
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: Malaysia
Posts: 3,376
Looks like you need to recurse and wildcard before you chmod the .attribute.

If you chmod the 755 back to 745 it will also.
__________________
"In a Time of Universal Deceit, Telling the Truth is a Revolutionary Act." - George Orwell
Vendot is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:05 AM   #3
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
You mean like this?

chmod -R *.cgi 755
chmod: invalid mode string: `*.cgi'
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:36 AM   #4
gallerypost
Confirmed User
 
Join Date: Nov 2001
Posts: 711
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 ;)
gallerypost is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:38 AM   #5
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
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?
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:43 AM   #6
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
.
__________________
MacDaddy Coder.

Last edited by boldy; 09-26-2002 at 07:45 AM..
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:46 AM   #7
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
Quote:
Originally posted by boldy
.
I know that. How do I do both though?
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:48 AM   #8
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
[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 .

Last edited by HQ; 09-26-2002 at 08:24 AM..
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 07:59 AM   #9
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
Told u

.

__________________
MacDaddy Coder.
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 08:23 AM   #10
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
Nope, I was wrong. That above command CHANGES ALL FILES just as running "chmod -R 755 ." would do.

FUCK!
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 08:26 AM   #11
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
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.
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 08:59 AM   #12
FuqALot
Confirmed User
 
Join Date: Dec 2001
Location: Malibu
Posts: 3,817
Hi,

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

Hope this helps.
FuqALot is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 09:07 AM   #13
salsbury
Confirmed User
 
Join Date: Feb 2002
Location: Seattle
Posts: 1,070
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.
__________________
salsbury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 09:35 AM   #14
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 10:04 AM   #15
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
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?
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 10:26 AM   #16
FuqALot
Confirmed User
 
Join Date: Dec 2001
Location: Malibu
Posts: 3,817
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.
FuqALot is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-26-2002, 10:52 AM   #17
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
Excellent. Thanks again.
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.