Yo DBAs, I am write a script – III
SARBJIT GILL
Blockchain Advocate, Enterprise Data Architect, DevOps Engineer, Senior Software Engineer, IT Research Mentor
Scripting: Which language which OS which interpreter ?
When it comes to the playground, there are many languages, many operating systems and many types of interpreters/compilers. This question will be raised only by a new learner who has not hit a need yet, but want to learn because one wants to be ready for nicely paying job. True, I was also thinking the same way, a few times at least. There is nothing wrong in this question.
For too eager scholars : language - shell scripting os - RHEL and interpreter BASH/KSH.
However, when I first heard that Chinese throw their toddler into a pond to force learning swimming, I was shocked, but when time came to me, I started to respect that tradition. You learn only when you need it, in other words when you get stuck. Such situation happened to me also about 4 times if i remember correctly. Basic requirement is your mental preparedness for being ready to learn NOW, not to put it off till tomorrow. Tomorrow never comes.
As far as DBA's requirement, (Windows) I strongly suggest to learn VBScript, Windows Batch or Powershell. Powershell is bit overkill, but once you get familiar, it is the most rewarding language. (*NIX) you should learn shell-scripting, perl and/or python. Shell is most useful and really handy but when it comes to volume processing, you will realize benefit of perl. Many would like to learn Java or C but those are more on programming side, but this works also if you are comfortable writing console applications. You will enjoy extensive variable and array space for your convenience where there is input of long or indefinite space requirement.
As long we understand scripting is very useful for small customizable tasks, we will enjoy it. In practice I have written over a few thousand scripts, obviously for DBA tasks. most astonishing scripts were health-check and SQL running scripts. I made my principal to write a script when I need to repeat any DBA command more than two times in a week. This enables me to pick up speed in doing my regular tasks 10 times easier, hence the speed thereby.
It is very important, if you can, write a script considering variations at os level. For example if you are writing a quick script to list databases on AIX, you can easily write the logic in one or two sentences in the script header, and it is also easy to consider the need in Solaris or RHEL. Once you use it on current role(AIX), I am sure you will forget it before you need it on next role (RHEL).
In next issue of this series I will give you a quick idea how to make your script adaptable to various environments. Trust me, it is very rewarding in term of mental satisfaction and also financially.