Difference between revisions of "Scripting"

From eLinux.org
Jump to: navigation, search
(Created page with "==Shell scripting== * [http://dberkholz.com/2011/04/07/bash-shell-scripting-libraries/ List of Bash shell-scripting libraries] * http://www.bashinator.org/ * http://code.goog...")
 
(wicked_cool_shell_scripts_2e)
 
(46 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
Scripting is powerful technology especially valuable in embbedded Linux. It is used for building complex projects, building root file systems and distributions, system management, tests automation.
 +
 +
Most commons shells are [http://www.gnu.org/software/bash/ bash] on PC and busybox's [http://en.wikipedia.org/wiki/Almquist_shell ash] on embedded Linux.
 
==Shell scripting==
 
==Shell scripting==
 +
* [http://www.gnu.org/software/bash/manual/bash.html Bash Reference Manual]
 +
* [http://www.makelinux.net/books/Bash-Beginners-Guide/ Bash Guide for Beginners]
 +
* [http://www.makelinux.net/books/abs-guide/ Advanced Bash-Scripting Guide]
 +
* [http://www.makelinux.net/books/GNU-Linux-Tools-Summary Command-Line Tools Summary]
 +
* http://wiki.bash-hackers.org/
 +
* http://bash.cyberciti.biz/
 +
* [http://www.cyberciti.biz/tips/linux-unix-commands-cheat-sheets.html Top 10 Best Cheat Sheets and Tutorials for Linux / UNIX Commands]
 +
* http://wiki.bash-hackers.org/
 +
* https://wiki.archlinux.org/index.php/bash
 +
* http://www.techbar.me/linux-shell-tips/
 +
* https://natelandau.com/bash-scripting-utilities/
  
 +
===Shell scripting libraries===
 +
* [http://www.gnu.org/software/shtool/ shtool] The GNU Portable Shell Tool
 +
** [http://www.makelinux.net/man/1/S/shtool man shtool]
 +
** Portable wrappers to standard operations
 +
** 3000 SLOC, 19 functions, bloated
 +
* [https://github.com/brandonprry/wicked_cool_shell_scripts_2e Wicked Cool Shell Scripts 2e] <small>[http://intuitive.com/wicked/wicked-cool-shell-script-library.shtml Wicked Cool Shell Scripts, 2004, samples]</small>
 +
** Indeed cool shell scripts, worth to read
 +
** Most in interesting functions: 015-newrm.sh, 016-unrm.sh, 021-findman.sh, 029-loancalc.sh, 037-zcat.sh, 038-bestcompress.sh, 040-diskhogs.sh, 084-webaccess.sh, 100-hangman.sh
 +
** 4000 SLOC, 100 files-functions
 +
** Easy to use
 +
* [http://marcomaggi.github.io/docs/mbfl.html mbfl - Marco's Bash Functions Library]
 +
** 5000 SLOC, 500 functions, bloated
 +
** The philosophy of MBFL is to do the work as much as possible without external commands.
 +
** Complicated to use
 +
* [https://github.com/lmartinking/monkey-tail @ aka monkey-tail]
 +
** 300 SLOC, 20 functions, simple wrapper functions
 +
** Easy to use
 +
* [https://github.com/makelinux/lib lib.sh]
 +
** Single script, 300 SLOC, 40 functions and aliases
 +
** Easy to use
 +
** Most useful functions: make-debug, trap_err, readline-bindings, duplicates, fs_usage, system_status_short, git_fixup, tcpdump-text, git_ign_add, for_each, mem_avail_kb
 +
====Specialized frameworks and libraries====
 +
* [http://www.bashinator.org/ Bashinator]
 +
** Logging framework
 +
** 700 SLOC, 18 functions
 +
** Complicated to use
 +
* [http://sourceforge.net/projects/libbash/ libbash - tool for managing bash scripts]
 +
** loads and unloads functions from scripts with commands source and unset
 +
* [https://github.com/SkypLabs/bsfl bsfl - Bash Shell Function Library]
 +
** 600 SLOC, 50 functions, logging functions, trivial wrappers
 +
** Easy to use
 +
* [http://code.google.com/p/shesfw/ shesfw - Shell Script Framework tool]
 +
** exported to [https://github.com/kennelbound/shesfw GitHhub]
 +
** 200 SLOC, 20 functions
 +
** unified interface to kdialog, Xdialog, zenity
 +
* [http://code.google.com/p/shunit2/ shUnit2 - xUnit based unit testing for Unix shell scripts]
 +
* [https://sites.google.com/a/forestent.com/projects/log4sh log4sh - logging framework]
 +
** logging framework for shell scripts that works similar to http://logging.apache.org/
 +
* [https://github.com/jpic/bashworks bashworks] - something messy
 +
* [https://github.com/rerun/rerun/blob/master/README.md rerun - a modular shell automation framework to organize your keeper scripts]
 +
** 700 SLOC, 30 functions
 +
 +
====Samples from books====
 +
* [http://examples.oreilly.com/9781565923478/ Learning the bash shell, 2005, samples], 62 files
 +
* [http://examples.oreilly.com/9780596526788/ Bash Cookbook, 2007], 99 files
 +
* [http://examples.oreilly.com/9780596005955/ Classic Shell Scripting, 2005]. 82 files
 +
 +
====Historical====
 +
* [http://examples.oreilly.com/9780596003302/ UNIX Power Tools, 1997, samples]
 +
* [http://www.cs.uleth.ca/~holzmann/C/shells/shell_book_blinn/ Portable Shell Programming, 1995, samples]
 +
** 1000 SLOC, 33 files-functions
 +
** Regular operations implelented in shell. Usedfull on out of memory (OOM) when there is no memory to run external programms.
 +
** easy to use
 +
 +
====References====
 
* [http://dberkholz.com/2011/04/07/bash-shell-scripting-libraries/ List of Bash shell-scripting libraries]
 
* [http://dberkholz.com/2011/04/07/bash-shell-scripting-libraries/ List of Bash shell-scripting libraries]
* http://www.bashinator.org/
+
 
* http://code.google.com/p/bsfl/
+
See also
 +
* [[Android Scripting]]

Latest revision as of 00:47, 25 June 2019

Scripting is powerful technology especially valuable in embbedded Linux. It is used for building complex projects, building root file systems and distributions, system management, tests automation.

Most commons shells are bash on PC and busybox's ash on embedded Linux.

Shell scripting

Shell scripting libraries

  • shtool The GNU Portable Shell Tool
    • man shtool
    • Portable wrappers to standard operations
    • 3000 SLOC, 19 functions, bloated
  • Wicked Cool Shell Scripts 2e Wicked Cool Shell Scripts, 2004, samples
    • Indeed cool shell scripts, worth to read
    • Most in interesting functions: 015-newrm.sh, 016-unrm.sh, 021-findman.sh, 029-loancalc.sh, 037-zcat.sh, 038-bestcompress.sh, 040-diskhogs.sh, 084-webaccess.sh, 100-hangman.sh
    • 4000 SLOC, 100 files-functions
    • Easy to use
  • mbfl - Marco's Bash Functions Library
    • 5000 SLOC, 500 functions, bloated
    • The philosophy of MBFL is to do the work as much as possible without external commands.
    • Complicated to use
  • @ aka monkey-tail
    • 300 SLOC, 20 functions, simple wrapper functions
    • Easy to use
  • lib.sh
    • Single script, 300 SLOC, 40 functions and aliases
    • Easy to use
    • Most useful functions: make-debug, trap_err, readline-bindings, duplicates, fs_usage, system_status_short, git_fixup, tcpdump-text, git_ign_add, for_each, mem_avail_kb

Specialized frameworks and libraries

Samples from books

Historical

References

See also