Tuesday, June 2, 2009

My First Linux Script.

from the days of DOS, Win95, and Win98 i was very curious about DOS batch scripting and automation. it's neat that you write a list of instructions for the computer execute. even setup a simple text-based menu driven interface using runlevels. DOS batch scripting was pretty powerful for automation back in the days, and the batch scripts i wrote were minimum 3 pages, maximum 10 pages long.

as the years went by a co-worker introduced me to AutoIt - a windows oriented scripting language similar to Microsoft's VB. and thus continued my fascination with scripting and automation.

this past semester i took a Linux class. one of the lesson covered was BASH shell scripting using the vi editor. most of my understanding about scripting came from prior experience of using AutoIt. the only difference was the syntax structure of the language.

one of the final labs for the class was to write a shell script where the user is asked to enter their name, the month born, and the year born. the output of the script was the acknowledgment of the user's name, and the calculate age based on the month and year. also there needed to be a loop to re-run the process until the user quits.

i submitted a scrip that covered all the requirements specified by the lab. it even contained multiple loops; after each question given is answered by the user, the script responds with confirmation before moving on to the next step.

you may download the script here.

all-in-all it was pretty neat, and well written for a newb. though i'm sure most of you Linux gurus could accomplish the same goal with only 4 lines of code. however it was my first attempt, and with Linux becoming a force to be reckoned with, hopefully it won't be my last.

peace,
@riel


1 comment:

sdinma said...

I dunno...the dialogue seemed a little wooden and there were plot holes you could drive a truck through. Maybe add an car chase or two to action it up a bit! I see Brad Pitt the lead and maybe Amy Adams as the love interest?