Bash/PowerShell scripting

Been working on several scripts/tools. One of which is utilizing ntfy.sh to help me stay on top of utilities that need to run without fail. An example would be a nightly backup script. Before email became locked down a person could have the device shoot off an email with details. Can’t really do that anymore, so something I’m going to do is stand up an internal only web server that hosts log files and such, and using ntfy.sh have it be a clickable action for that specific log file it hosts in the event I need to read it. I’ll post more on this as it comes together.

As for PowerShell I use it on the Windows side since it’s pretty robust and a good bash equivalent in terms of functionality. They are most definitely not a 1-1 comparison but in terms of getting work done I use both. One feature I use between the two is functions to allow for repeated code to be easily accessible. An example would be an installer function that launches the setup program, catches the exit code and uses that to determine if it was successful in conjunction with testing a file/directory path. In doing so I can automate error checking and logging where needed for installation tools. I designed this when I needed to walk myself through a set of program installs that had to be done in a specific order across multiple reboots with a high chance of interruption. This made it so I could mark off what step I was on into a file and ensure that it was ok to do so based on defined parameters. In PowerShell, I’m able to define variables that are required and give them proper names. This is one thing PowerShell does without much hassle compared to bash, but I’m looking into the bash equivalent and it looks easily doable as long as I don’t forget to make sure all variables are cleared before usage within the function, avoiding errors and such in the process.

Leave a Reply

Your email address will not be published. Required fields are marked *