The Power of scripting
why and how to promote
scripting languages
in schools and small businesses
Marco Fioretti

http://m...
Author introduction
Marco Fioretti
Member of
OpenDocument Fellowship (www.opendocumentfellowship.com)
Digistan.org (www.di...
Agenda
What the command line and scripting
languages really are
Practical examples
Conclusions: why scripting languages ar...
What is a graphical user interface (GUI)?
A GUI is an environment in which the computer
visually tells you what can be don...
What are shells,command lines, terminals?
A command line is a place, inside a text terminal
window, where the user can wri...
GUI vs Command line: visual comparison
The GUI shows what is the content of a folder:

Marco Fioretti (marco@digifreedom.n...
GUI vs Command line: visual comparison
A shell tells the user what is the content of a folder

Marco Fioretti (marco@digif...
GUI vs Command line: visual comparison
To move files and folders in GUIs, the user must point to
those objects and to the ...
GUI vs Command line: visual comparison
To move files and folders in the terminal, the user tells the
computer where those ...
GUI vs Command line: what's the difference?
There are many cases where a GUI is much more efficient (e.g.
picture editing,...
And another HUGE difference is...
The fact that textual commands don't need to be given in real time!
To repeat gestures y...
What are scripting languages?
A scripting language is a computer language which has an
interpreter, that is a separate pro...
What does a script look like?
Declaration of which
interpreter must be used

comments

Variable
assignments

Marco Fiorett...
Examples with OpenDocument scripting
The OpenDocument Format (ODF) which is the default format
for OpenOffice...
...is not...
Examples (1): Generate OpenDocument invoice
marco => cat my_data.sh
INVOICE_DATE='2010/05/15'
VENDOR_CODE='007'
PO_NUMBER=...
Example (2): Spreadsheets with working graphs and formulas

+

Time-of-day
Midnight

•
•
•
•
•

BW 1
4.5
6.3
3.1
1.85

BW2...
Example (3):Slideshows drafts from plain text outlines

Q: how did I
generate the
first version of
this
slideshow?

A: wit...
Other things very easy to do with ODF
Format math formulas and exercises created with Mathematica
Generate course DVDs fro...
Image processing with ImageMagick
The ImageMagick tools (www.imagemagick.org) can be run at the command line or inside a
s...
Automatic (collaborative) picture geotagging
Minimap is a
Firefox extension
that lets the user
create lists of
points of i...
Automatic (collaborative) picture geotagging (2)
The Minimap user needs to know nothing about geotagging or
geographical c...
Automatic, collaborative picture geotagging (3)
Coordinates captured with Minimap can then be automatically
inserted insid...
Flow for (collaborative) geotagging
Create plain text listing of place names and their coordinates with Minimap:
Cannigion...
Flow for (collaborative) geotagging (2)
Run one script that:
Reads the two lists
Associates to each picture its coordinate...
Advantages of collaborative geotagging
Lists of coordinates must be created only once for
each point of interest
It can be...
Conclusions: what's the power of scripting?
Computers should save our time, not waste it!
Scripting can save huge amounts ...
Why is scripting so powerful?
Because it is equivalent to moving from sign language to real
language
We have ten fingers t...
Last but not least...
Even if you're an absolute beginner, there are
thousands of scripting tutorials and practical
exampl...
Note for Free/Open Source Software activists
Explaining the power of scripting can also be an
effective way to introduce t...
Resources
ODF scripting
http://freesoftware.zona-m.net/odf-scripting

Collaborative geotagging:
www.tuxradar.com/content/g...
Upcoming SlideShare
Loading in …5
×

The Power of scripting

650 views

Published on

Why and how to promote scripting languages
in schools and small businesses: "it can save a huge amount of work!"

Background: these are the slides of my talk at the 2010 Free Software conference in Kosova. For details, read http://mfioretti.com/power-scripting-why-and-how-promote-scripting-languages-schools-and-small-businesses

Published in: Technology
  • Be the first to comment

The Power of scripting

  1. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
  30. 30. Resources ODF scripting http://freesoftware.zona-m.net/odf-scripting Collaborative geotagging: www.tuxradar.com/content/geotagging-linux www.linux.com/archive/feature/147564 Command line recipes www.commandlinefu.com Questions? For more info: marco@digifreedom.net Marco Fioretti (marco@digifreedom.net) http://mfioretti.com http://stop.zona-m.net August 2010, Prishtina Software Freedom Conference Kosova Some Rights Reserved 30

×