Using the Main function
It is a good practice to make a function do only one thing. This means that, when writing a script that must do a series of tasks, you will need multiple functions. In such a case, one function will call another to perform the task. The structure of the script, then, would be to have the called function written before the calling function. When working with several functions within a script, the entire structure could look upside-down.
Now, reading and understanding the script may feel a little challenging.
For instance, I wrote a script for one of my clients that helped them heal a Citrix Virtual Desktop Agent server if it unregistered itself from the Controller for any of several reasons. This script was over 300 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access