Tuesday, February 8, 2011

Adventures in Python code.

My Unisa studies have led me to the Python programming language, as mentioned before. Since then I have endeavoured to apply my knowledge on as many fronts as I can.

 

One of the first things I have done is to create a very simple host monitor.

 

Of course I could do this without Python, but where’s the science in that J ?

Python has a nice feature that allows you to run an OS command and write the results back to a variable. If I am not mistaken many other scripting languages have similar features.

 

So I do something simple like:

variable = os.popen(“ping hostname”).read()

 

This was the easy part. The parts that kept me busy were things like parsing strings for certain characters, saving results to external files, loading previous results and doing comparisons with them etc.

It’s still a work in progress, but it works.

 

The final bit was to import the results files into Excel to give me a visual of hosts on my network, which worked like a charm! Set the links to update every few minutes, schedule the script to run in the background, and you have a live view of your network!

 

I won’t put the entire set of scripts here since it is really basic stuff (and I would be showing how amateur I still am), but maybe later I’ll consider it J.

 

 

 

 

Tuesday, February 1, 2011

Study time again...

So, back to the old routine of getting up real early in the morning
(3:00AM) to further my studies.
The studies are fun, but dragging my tired body out of bed when decent
people should be sleeping most certainly isn't. Coffee stops helping
after a while.

It's amazing how many typos your Python code contains at 3:30AM. Even
more amazing is the reduced ability to understand why the code won't
run.

Strangely however, this still works better than trying to stay up late
for studies. Performance (and the will to continue) is worse at 1130PM
than at 3:30AM.

Strange but true.