Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Bash Scripting

So at our work we have (I know this should be in the Mac section but they are mostly retards spurting mac is great, mac is god)

2 Macs
1 Windows XP Computer
1 Mac Server

And we have a permissions error on the server which makes it so one mac can't read anothers file and it's being a bitch that I'm not in the mood for fixing and I'm also to busy to do so and I've just got a simple bash script at the moment like this

Code
#!/bin/bash
cd '/Shared Items'
chmod -R 775 Photos
echo "Photos Successfully done"

Is that right or is there a better way to do it?

And then to run that every minute or so, just add it to a cronjob? Or would it be easier to make another script on my bosses computer so that whenever the permissions play up she can just click that and it would fix everything (It would have to login over SSH though)
Hiring PHP developers does not contribute to the quota of employees with disabilities.
[Image: lPQX27G.png]

(May 17, 2015 08:27 PM)♕ Pimp ♕ Wrote:  you're a waste of my time and giving me cancer.
You could consider moving them into a group and give that group permissions.
Else it is looking fine.

You could also try chmod 775 /$FOLDER/*
It should change all permissions inside folder to 775.

I wont recommend adding it to cronjob to run every minute or so.
[Image: 4bj39qK.png]
Just keep in mind, whether it successfully works or not, it's going to print the success message. It has no kind of error control (which for your implementation is probably fine, this is changing file permissions, not rocket science, lol)

If you do decide to run it as a cron, you should probably use absolute paths instead of relative (including the commands), since I've had a number of scripts run fine when executed by a user, but break when trying it as a cron job. Adding the ab paths fixed it. Also, I agree with the sentiment that a cron job ever couple minutes for something like this probably isn't a great idea.
chmod 775 /$FOLDER/*
means that just the permissions on files and directories inside $FOLDER get changed. Thus $FOLDER/file but not $FOLDER/folder/file ...

@OP
your script looks fine. There are probably better ways to do this but it will work adding it to cron.
/path/to/script

Yes,
is allowed thus it being run all the time.

Cron explanation if you don't know how.

# * command to execute
# ┬ ┬ ┬ ┬ ┬
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)
My mistake, forgot the option.

He would need to put -R behind chmod.

so the command would look like this:
Code
chmod -R /$folder

-R =
Quote:-R, --recursive
change files and directories recursively

[Image: 4bj39qK.png]
(Mar 27, 2014 10:52 AM)Trip2nite Wrote:  My mistake, forgot the option.

He would need to put -R behind chmod.

so the command would look like this:
Code
chmod -R /$folder

-R =

The -R flag was there aldready 🤫
How the...
I guess I'm to tired, so I better go to bed.

Code
sleep 12h
[Image: 4bj39qK.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
by kingpzzoJan 9, 2016 04:28 PM 0 110 Jan 9, 2016 04:28 PM
Last Post: kingpzzo
by cewaApr 27, 2015 11:33 AM 9 196 Apr 27, 2015 11:33 AM
Last Post: cewa
by Blackhat.rlshDec 5, 2012 04:32 PM 2 111 Dec 5, 2012 04:32 PM
Last Post: Blackhat.rlsh