Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, October 9, 2019

Learning Basic Bash scripting

So I have been working on a new project which requires a lot of repetitive inputs, and me being let's say lazy have been working towards scripting the commands out.   Currently, I have been working mostly with Bash scripting since I can't add any new complexities to the environment.  Basically, work with what's available. 

For one I think that automating or scripting is better overall in creating a standard load.  It might be wrong, but at least all systems will be wrong right?  This way you are taking away the human element which doesn't get me wrong they are trying to follow the directions, but sometimes the instructions are not written to their level and take assumptions into play. 

With the use of scripts, you can have almost anyone run it, as long as you have outputs defining what is occurring and the proper error detection/collection, which is where I am currently at in my hell.

The scripts are basic in add users, copy some updated files over system files, install a few packages, install signatures, etc.  For the most part, the scripts run, now its time to go back and provide comments per the sections, validate a log file is being created with everything, and proper error detection (This is where I am getting some assistance).

Another great tool is to have code review by somewhere else, as they will see it in a different light and provide possible other ways to get the job done, and/or see issues with the script. 

Till a few days ago I didn't even know what 2>&1 was used for, I mean I had seen it a few times, but hey let's throw that in the script just to see what it does.   But I started using it to redirect output from the script to the screen and to the log file (as I saw in another script).  Reading more it redirects stderr to stdout.

The next was the use of variables in the bash script.  I have used it in programming languages like Java, C++, but I guess I didn't realize that you could use them in something as simple as a Bash script.

Last was the use of the If/Then clause, another concept I am used to in Java/C++, just didn't think it was useable in Bash scripts, well here's to learning what other cool things I can do with Bash.
   

Sunday, April 26, 2015

Lightbox Game for Windows Review

The other day I was searching for some coding games to let my kids try them out.  Currently they are addicted to Minecraft.  I was looking for something new that they could try on the computer and try and stimulate their brains to think.

Lightbox reminded me of Robot Turtles which I bought I believe two Christmas's ago for my kids, and they love that game.  I like that Lightbox is on the computer and the girls can see quickly if they made a mistake and then try new things.

And there are different levels to the game.  In Robot Turtles  I broke it down to levels but the way LightBox does it I think it makes it easier on me for explaining.  Robot Turtles I would have to explain what a program was and how to run it.

In Lightbox they can test and run, test and run, till they figure it out.  And if they do not understand it then I can lend a hand.  My oldest daughter got up to Level 3, while my youngest is currently at Level 2.

Each level has about 8 stages, with Level 1 basic commands like: Forward, Light, Turn left, Turn Right, and eventually Jump.  Level two they add the PROC command which to me is like a sub-routine you can run in your main command. This will give you the ability to have an additional 8 commands.   I used the PROC command for routine repeated commands (which I gather that was what it was for).  On average it would save a few "lines" of code in the main routine.

In Level 3 you get the PROC 2, which enables looping of the PROC 1/PROC 2, and adds another 8 commands to your chain.

Overall I think the game is a great tool for kids to learn function, routines, and problem solving.  The controls are basic and easy to use that even my youngest was able to start right up.   The game was built using flash.  The game was built during the Hour of Code event.

Additionally on their website you can sign up for an alpha of a new programming game being built.