[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Minutes from the ILUGC meet - November 25th, 2000



*****************************************************************************
          Minutes of the ILUGC meet - November 25, 2000
*****************************************************************************

      This meet was no different from all the other meets characterised by a
late start and a feeble attendance. The meet was flagged off at 4:00. A good
number of new-comers helped fill up the 17-member-attendees-list. 

      The agenda of this meet were:
         1. Talk on 
            * Advanced bash scripting
            * Python Scripting 
                     -- By Prabhu

      Mr.MKS's Internetworking lectures have been postponed to the next meet due
to a majority's request as most of the students in the campus are holidaying.
(Suraj's dreams shatterred! )-:)

      Prabhu didn't do the advanced bash-scripting and has plans to push it to
the next meet. However he gave an intro to bash scripting starting from the
roots: the difference between a compiler and an interpreter.

      Placing the worn out felt pen on the board prabhu started "BASH stands for
Bourne Again Shell". It is a better version of the traditional unix shell - sh.
Infact in some of the distros /bin/sh is a symlink to /bin/bash!. The shell is a
n interface to the Operating System. It is THE program that makes the computer 
useful. He explained the features that any standard unix shell provides : pipes,
redirection, job control, etc., 

      Shell scripts are a set of shell commands (or any other programs) set in
sequence to achieve a required task. Shell scripts are synonymous to the DOS
batch files and are more powerful than batch files. Shell scripts are
interpreted. Explaining how an interpreter works, he moved further to explain
the compilcations of using a compiler for trivial tasks such as renaming a group
of files. 
     
      Compilers like gcc take a source code, parse it, map symbols and then
links the libraries with the object code. But interpreted languages don't work 
that way. They read a high level language code and convert it to machine code 
line by line. The type of binaries (produced by compilation) depends on the 
architecture. So interpreted languages "rule!" in this territory but when it 
comes to performance, its compiled code thats fast.  

      bash has some nice control statements like if-then-elif-else-fi,
while-do-done, for-do-done. 

	 Job control statements like fg, bg, etc., were explained. bash scripts can
be very useful for job management purposes such as killing 10 processes of
netscapes. The serious talk broke into a laughter when Mr.MKS cracked "Why
should we have to kill netscape processes? They just kill themselves!" and Mr.
Asokan replied "Just in case they dont?"
    
	 He also explained how bash executables are constructed with a 
#!<interpreter> with multi-colored felt pens that emulated syntax 
highlighting on the white board.

     More for Practical stuff...

     Mr.Asokan joined prabhu to share a few of his experiences with shell
scripting.

     In the good olden days... there lived a harddisk with a lot of disk space
but with little inode space. This hard disk was running out of inode space
not because of any poorva janma sins but due to enthusiastic students
writing hello world programs in his Training centre. teaching the
student "how to use tar?" will be beyond the scope of the syllabus so one
way was to ask him have a directory in his home for storing programs. Then
a shell script will be run by the sysadmin to put all the files into one
big file.

     Another modern day problem that crippled in was using the funnily designed
tpyp (Tata Press Yellow Pages) cdrom. This CD-ROM had a directory like
structure full of HTMs containing the Name, Section, Address, Phone, etc.,.
Some fields were delimited by ":" and some by the HTML equiv for Line 
Break -- <BR>. The shady part was the Address that was seperated by
nothing. For example my address would be written
16bNsrroadNehrunagarChromepetChennai600044. Luckily this one's a better
example. Some had just two digit pin codes! The Phone numbers were preceded
with a "Ph.". First all the <BR>s were replaced by ":"s. Thanks to unhtml,
all the HTML tags were removed. Then came Mr.Sed. sed s/Ph\./\:/g, All
phone numbers were seperated by a ":" Now was the problem. The Address. It
was python that came into help. 

     All this struggling (thanks to the shell) what is the use? Sooner
Mr.Asokan's Company tied up with TPYP and had the damn database available
in  MS-Access Database format!
	 
    chennaionline.com, hosted on the other OS, needs to be checked for hits and
frequency of which pages are used and which are not. The Other OS's server
logs in a W3C compliant Flat File. Though there was (Oh! I forgot the name
of that software!) a windows software available for reading the logs, it
wasn't as efficient. So here rolls out a shell script. The necessary field
(The Object that is demanded) is extracted using `cut' and piped to sort
then to uniq -c. This way, they were able to count the number of hits.
	
	 
     For more information read the bash man pages.

     All bashing and no python will be an incomplete meet with an unfulfilled
agenda. Luckily prabhu knows python better than english, so he had no problems
triggerring the 0x1earn_python interrupts (or is it interest?) in us (-:

     Python is an Advanced Object Oriented Interpreted High-Level Language. It
is easy to learn. The only difficult part of it is the name of its developer :
 "Guido Von Rossum" (phew... let me gasp). Python was a GNU product hence it 
 soon became "The choice of the GNU Generation"! 
 
     Still there are people who dont like python because of its lack of using 
parantheses to represent blocks of code.
 
 It has the following features to its advantage:

               * Scripted
               * High-Level Data types
               * Reference Counted
               * Object Oriented (Supports Classes, Inheritance, Polymorphism)
               * Dynamically Typed
               * Free DOCs available
      
      Python has two classifications in its data types: 
               1. Immutable             2. Mutable. 

      Immutable data types are like that of constants. It cannot be modified by
any python code. One such data type is the Tuple. A Tuple is like a const
struct. It is there and will always be there. The Unshakeable!. Where as a
mutable data type like list can be changed by the member functions of that
class. 

      Python's features can be explained as follows:
    
      Scripted: It is interpreted, so it is platform independant as long as an
interpreter is available for the platform under argument.
   
      High-Level Data Types: It has every data type that is expected of a
 high-level language plus more. It can get a whole file into a list or a big
 string. Name it and python does it for you! Python features Hi-Fi data types
 such as lists, tuples, dictionaries, etc.,
 
          A List is essentially an array. But it can hold just anything (Even
      functions!) A Dictionary is a key-value pair of elements. The elements can
      be accessed by their respective keys (similar to perl's key-value pair
      stuff)

      Reference Counted: The functions dont take copies of the arguments. They
merely take a reference (in the C world, a pointer) to the actual object that
has been passed. This means a much smaller memory requirement even when working
with large data types. Python has one drawback (Even the strongest Superhero has
to be hit by the villians at least once, isn't it?): Garbage Collection. If
there is a reference to an object and if the object is deleted, the reference
still exists. Fine that's not the problem. But for cyclic references, say A->B
and B->A and del A and del B. Doesn't clear both objects. However this is fixed
in the upcoming version of python (Afterall people will get bored if the villian
keeps winning (-;). 
            
            Moreover python has support for modules. Modules which have python  
       classes can be included by issuing the command import <module>. Modules
       are imported in name spaces. A Module say X's variable say A can be 
       accessed as X.A . 

            Object Oriented: Python is very object oriented. By this it means 
       that it has support for classes, inheritance, polymorphism, etc., 
       function's parameter can be anything as long as the function uses an
       available member of the parameter object. This leads us to Polymorphism.
       Functions, operators can all be overloaded.

             Dynamically Typed: None of the variables need to be declared 
       implicitly. Python automatically initialises the variables depending 
       upon the content. 


     Reading the python-doc is highly recommended to learn python.
	
     People who are interested in teaching trivial things such as
tar,gzip,etc., are requested to volunteer. 

    The usual CD Exchange took place. What happenned next. This small shell
    script should do:
    $ mv swaraj redhat_7.0_guru
    $ for i in `members`
    >do
    >laugh $i
    >done
	
    (-;

             "I Like python because it fits my brain"
                                            --Anonymous on Deja



     -Suraj
---
Visit our home page at: www.chennailug.org
Send e-mail to 'ilugc-request@xxxxxxxxxxxxxxxxxx' with 'unsubscribe' 
in either the subject or the body to unsubscribe from this list.