The document discusses the power of scripting languages and provides examples of how they can be used in schools and small businesses. It begins with an introduction to scripting languages and how they differ from graphical user interfaces. It then provides practical examples of using scripting with OpenDocument files to generate invoices, spreadsheets, and slideshows from plain text. Other examples shown include using scripting to process images and automatically geotag photos. The document argues that scripting is more efficient and saves time, and that even beginners can learn scripting through online tutorials. It concludes that explaining scripting can be an effective way to introduce people to free and open source software.
1. The Power of scripting
why and how to promote
scripting languages
in schools and small businesses
Marco Fioretti
http://mfioretti.com
http://stop.zona-m.net
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
September 2010, Prishtina
Software Freedom Conference Kosova
Some rights reserved
2. Author introduction
Marco Fioretti
Member of
OpenDocument Fellowship (www.opendocumentfellowship.com)
Digistan.org (www.digistan.org)
Writer for Linux Journal, Linux Format, Pc Professionale and other
magazines
Author of the Family Guide to Digital Freedom (http://digifreedom.net)
Co-author of the O'Reilly Open Government book
Home page and writings:
http://mfioretti.com
http://stop.zona-m.net
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
2
3. Agenda
What the command line and scripting
languages really are
Practical examples
Conclusions: why scripting languages are
good for schools and small businesses
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
3
4. What is a graphical user interface (GUI)?
A GUI is an environment in which the computer
visually tells you what can be done, showing
possible choices in buttons or menus
And the user manually indicates (mouse clicks) what
he or she wants to do. Every time...
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
4
5. What are shells,command lines, terminals?
A command line is a place, inside a text terminal
window, where the user can write, that is declare in
writing, whatever he or she wants the computer to do
Depending on the context, a shell is either an
environment in which the user can give commands to
the computer, or an interpreter of those commands
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
5
6. GUI vs Command line: visual comparison
The GUI shows what is the content of a folder:
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
6
7. GUI vs Command line: visual comparison
A shell tells the user what is the content of a folder
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
7
8. GUI vs Command line: visual comparison
To move files and folders in GUIs, the user must point to
those objects and to the place where they should go
Select object
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
Drag it to destination
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
8
9. GUI vs Command line: visual comparison
To move files and folders in the terminal, the user tells the
computer where those objects should go
mv = “move this here”
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
9
10. GUI vs Command line: what's the difference?
There are many cases where a GUI is much more efficient (e.g.
picture editing, drawings...)
But also many others where the difference between GUI and
command line users is the same that there is between a toddler
pointing at objects and an adult saying “I need to do this”
Ignorance of real speech (GUI) = much more communication
limits, that is much more effort and time wasted to tell the
computer what it must do
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
10
11. And another HUGE difference is...
The fact that textual commands don't need to be given in real time!
To repeat gestures you must either repeat them or make a movie
To repeat many text commands, you can just type them all, once,
into a file...
...that the computer is able to read by itself!
And all this is much, much, much simpler than real
programming!
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
11
12. What are scripting languages?
A scripting language is a computer language which has an
interpreter, that is a separate program that:
Reads the commands written into files called scripts, one at a
time
And executes those commands, one at a time
Without asking the user to take care of variable declarations or
typing, memory allocation, compiling code and so on!
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
12
13. What does a script look like?
Declaration of which
interpreter must be used
comments
Variable
assignments
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
These are the actual commands that
the script will executes for you
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
13
14. Examples with OpenDocument scripting
The OpenDocument Format (ODF) which is the default format
for OpenOffice...
...is nothing else than ZIP archives containing plain text files and
other objects (e.g. images) in normally standard formats
Therefore, it is very easy to create or analyse office texts,
presentations and spreadsheet automatically...
...using the many FOSS tool created just to process plain text
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
14
15. Examples (1): Generate OpenDocument invoice
marco => cat my_data.sh
INVOICE_DATE='2010/05/15'
VENDOR_CODE='007'
PO_NUMBER='Purchase Order #1'
TOTAL=10
ISSUE=150
DESCRIPTION='Here is your invoice'
1 ASCII data file
+
35 lines shell script
Result directly
Usable in
OpenOffice!
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
15
16. Example (2): Spreadsheets with working graphs and formulas
+
Time-of-day
Midnight
•
•
•
•
•
BW 1
4.5
6.3
3.1
1.85
BW2
6.4
6.3
6.1
5.87
Still editable
formulas!!!
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
16
17. Example (3):Slideshows drafts from plain text outlines
Q: how did I
generate the
first version of
this
slideshow?
A: with the same
trick used in the
spreadsheet
example, same
scripts complexity
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
17
18. Other things very easy to do with ODF
Format math formulas and exercises created with Mathematica
Generate course DVDs from existing slideshows
Generate printable versions of multiple choice tests created in
Moodle for online teaching
Automatically import content of spreadsheets or texts to databases
Automatically add watermark or caption to each image in many
texts or presentations
Reduce image resolution, to save disk space
replace company logos or other clipart
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
18
19. Image processing with ImageMagick
The ImageMagick tools (www.imagemagick.org) can be run at the command line or inside a
script to:
Automatically resize all your
pictures
Generate thumbnails for web
publishing
Add captions, frames or
watermarks to them
Example from
www.rubblewebs.co.uk/imagemagic
k/compair.php
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
19
20. Automatic (collaborative) picture geotagging
Minimap is a
Firefox extension
that lets the user
create lists of
points of interests
and of their
geographical
coordinates
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
20
21. Automatic (collaborative) picture geotagging (2)
The Minimap user needs to know nothing about geotagging or
geographical coordinates at all
1) click on point of interest in Google Maps
2) give it a name and optional description in
the Minimap pop-up window
3) repeat for as many other points as you
like
3) save all place names and coordinates as
ONE plain text file
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
21
22. Automatic, collaborative picture geotagging (3)
Coordinates captured with Minimap can then be automatically
inserted inside digital or scanned photographs with the Exiftool
utility
Coordinates!
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
22
23. Flow for (collaborative) geotagging
Create plain text listing of place names and their coordinates with Minimap:
Cannigione Harbour: Long: 9.01E, Lat 42.03N
Cannigione Church:
Long: 9.04E, Lat 42.06N
...
Create plain text list that associates each picture to a place
picture_1.jpg: Cannigione Harbour
picture_2.jpg: Cannigione Church
picture_3.jpg: Cannigione Harbour
.....
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
23
24. Flow for (collaborative) geotagging (2)
Run one script that:
Reads the two lists
Associates to each picture its coordinates
Tells the exiftools program to write those
coordinates in the EXIF standard format inside
the corresponding JPG file
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
24
25. Advantages of collaborative geotagging
Lists of coordinates must be created only once for
each point of interest
It can be made with Minimap, that is extremely easy
to use and multiplatform, just like Firefox
Being plain text files, lists of coordinates by many
different people can be merged without problems
The person that runs the script can be somebody else
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
25
26. Conclusions: what's the power of scripting?
Computers should save our time, not waste it!
Scripting can save huge amounts of time in all areas of
computer work!
The examples presented are directly relevant and useful in
any school or small business
Scripting automates creation of homework, exercises,
budget reports...
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
26
27. Why is scripting so powerful?
Because it is equivalent to moving from sign language to real
language
We have ten fingers to type on 101 buttons, only one hand to
move one mouse: what's more efficient?
Therefore, scripting makes it much easier to quickly explain to
your computer all you want it to do for you
No matter what you do with computers, there surely is
something that can be automated by scripting
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
27
28. Last but not least...
Even if you're an absolute beginner, there are
thousands of scripting tutorials and practical
examples online
Scripting is multiplatform: while it is already
“built-in” in any Gnu/Linux distribution, the same
scripts can also be run on Windows or Mac systems
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
28
29. Note for Free/Open Source Software activists
Explaining the power of scripting can also be an
effective way to introduce to FOSS many people
that would be intimidated or bored by other
approaches
Did you notice that in all these slides there is NO
mention of: source code, sw licenses etc...?
Marco Fioretti (marco@digifreedom.net)
http://mfioretti.com
http://stop.zona-m.net
August 2010, Prishtina
Software Freedom Conference Kosova
Some Rights Reserved
29