Sharing some useful tips, solutions and notes for Geeks.

Wednesday, March 14, 2018

Remove complete permission of a file via sh shell command

I was in a situation where we donot execute a php file via browser. It should only triggered when its called via cron job.

So to overcome this issue, i have written a small shell script to execute this.

Now, how can we remove complete permission of a file so that it shouldnot work whilst called via URL.

..thinking..

..thinking..

..thinking..

Actually its possible.

chmod ug= ourfile.php 

This will remove read and execute permission for the group and user.

And Voila.. it worked out..

Now when called via browser, we gets 404 not found.

So in the shell script, i first set the file to executable permission, then execute the php and at the end above command is executed.

Try it out.

No comments: