r/ScriptSwap • u/loganbest • 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?
View all comments
Show parent comment
1
u/rodmacpherson Bash CMD Python PowerShell Jan 10 '13
Use google to help you. What you needed was to know how to accept an arguement or parameter (the "on" and "off") how to do if and/or case and the shell command to move a file. (mv) it's not hard if you don't know how to say what you want to say in the language you are trying to use then look it up. There are a ton of resources online giving the syntax for any language you want to use.