What is a script?
A script is a set of commands, either in a file, or typed in at the command line, that perform multiple operations on a file or files.
How do they work?
To run a file as a script, the file must have the execution bit set
Best Practices
¨ Writing clean code, using indents and using comments to explain parts of your code.
¨ Defining variables properly and avoid using unnecessary ones.
¨ Proper usage of functions. This would help edit, replace parts of the scripts easily without proper functioning of the base script.
¨ Using log functions as when needed
¨ Putting usernames/passwords in scripts should be avoided.
¨ Hard-coding hostnames, files directory paths in a script should be avoided.
¨ The same form should be maintained throughout for the code. Inconsistent coding styles make debugging a lot harder regardless of who's doing it.
¨ Proper documentation is very much needed.
¨ Proper testing needs to be done on Non-Production before implementing the scripts in a production environment.
¨ Generic scripts should have a common and understandable name.
¨ Understand the requirement and scope as where shell scripts can be implemented and where not.
No comments:
Post a Comment