r/ScriptSwap • • Jan 10 '13

[request] htaccess maintenance script

I'm wanting to write a script that will loop through each of my web roots, check for a .htaccess file AND a .htaccess_maintenance file.

  • This script will have a stdin variable of either "on" or "off".
  • If "on" it will find the production .htaccess rename it to .htaccess_live then rename .htaccess_maintenance to .htaccess.
  • If for some reason .htaccess_maintenance doesn't exist it'll create it then rename it to .htaccess
  • If for some reason the site doesn't have a live .htaccess file, it will only rename .htaccess_maintenance to .htaccess.

  • This will all reverse if stdin is "off"

Here's the caveat, I'm a noob at shell and perl scripting. I can read it and understand it 100%, but I just don't know enough to write from scratch. I would much rather write this script myself in either language than have someone write it for me.

My ultimate question is, how can you help me write this with specific examples or resources?

3 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/loganbest Jan 11 '13

Yep. I've never taken any programming classes in my life but I've taught myself VB6, VB .NET, Java, Python, PHP, RoR, etc. just about everything except Perl and bash scripting. I learn more everyday but having nice clean code examples like yours really make my learning better.