Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-27-2013, 01:43 PM   #1
Baseband Member
 
palermo's Avatar
 
Join Date: Jan 2013
Location: United States
Posts: 81
Default UNIX Script to chmod other scripts?

Would it be possible to write a script to chmod all files ending in .sh to change permissions to say 777?

I'm practicing my UNIX Scripting and before I run the script from the command-line I have to change the execution bit or I get denied.

I would like to create all my scripts then run my, I'll call it "chmod.sh" which would "chmod 777 *.sh" all my .sh file. Is this possible, if so, how would I go about writing this script?

Thank You.
__________________

palermo is offline   Reply With Quote
Old 05-28-2013, 07:23 AM   #2
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: UNIX Script to chmod other scripts?

Quote:
I'll call it "chmod.sh" which would "chmod 777 *.sh" all my .sh file.
That's exactly what you need!
__________________

__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 05-28-2013, 08:38 PM   #3
Baseband Member
 
palermo's Avatar
 
Join Date: Jan 2013
Location: United States
Posts: 81
Default Re: UNIX Script to chmod other scripts?

What would the actual script look like. Would it a for-in-do style?

for %%d in (/home/john) do chmod 777 *.sh

I'm not sure where the second part of the variable would go or if I would need it.
palermo is offline   Reply With Quote
Old 05-28-2013, 08:39 PM   #4
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: UNIX Script to chmod other scripts?

You don't *need* the loop at all - that's what the wildcard does (applies the chmod operation to each shell script in the current folder.) It's literally just:

chmod 777 *.sh
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 05-28-2013, 09:31 PM   #5
Baseband Member
 
palermo's Avatar
 
Join Date: Jan 2013
Location: United States
Posts: 81
Default Re: UNIX Script to chmod other scripts?

Thanks. I'll give it a go
palermo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:30 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0