1 / 16

Sydney Oracle Meetup

Sydney Oracle Meetup. Shellfish Shells for Distinguished DBAs!. Agenda. What are they? Why you should care? Why I will talk about BASH only Learning BASH Readline Set The Good, The Bad and The Ugly Focus is on BASH only External commands won’t be covered. Built-ins will.

fia
Download Presentation

Sydney Oracle Meetup

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sydney Oracle Meetup Shellfish Shells for Distinguished DBAs!

  2. Agenda • What are they? • Why you should care? • Why I will talk about BASH only • Learning BASH • Readline • Set • The Good, The Bad and The Ugly • Focus is on BASH only • External commands won’t be covered. Built-ins will. • Won’t be talking about whiz bang custom functions. • Presentation is for Oracle DBA’s familiar with Shells already.

  3. What are they? • Interactive User Interface into an Operating System. • Exist for all Major Operating Systems. • GUI Shells: • Gnome • KDE • Windowsexi • Command Line Shells: • Bourne (sh) • Korn (ksh) • C (csh) • Tcsh (tcsh) • Bourne Again (bash) • Powershell • And more...

  4. Why you should care? • Are lightweight compared to GUIs. • Allow a high level of control. • Today’s implementations are opensourceand similar across OS. • Easy to program and automate repetitive tasks. • Good knowledge of shell scripting means you can think more and work less!

  5. Why I will talk about bash only • Default Shell for many modern Operating Systems. • Ongoing development - still supported. • Most (not all of course) Oracle DBAs will use this Shell on a UNIX OS. • Time.

  6. How to learn Bash? • Login to a shell and type “man bash” • Look at sample code. • Automate your everyday tasks. • Go to the Gnu BASH website - http://www.gnu.org/s/bash/

  7. Useful readline settings • Custom settings stored in ~/.inputrc • set horizontal-scroll-mode=on • set completion-ignore-case=on • set mark-symlinked-directories=on • set show-all-if-ambiguous=on • set visible-stats=on

  8. Readline commands • CTRL-R / CTRL-S search history • CTRL-A / CTRL-E move to beginning / end of a line • CTRL-L to clear screen • ESC-B / ESC-F move backwards and forwards between words • CTRL-X + CTRL-E edit the command in your EDITOR (good for long commands) • ESC-{ expand all filenames and encapsulate in brackets

  9. set • set dump environment • set –e exit immediately (or go to trap handler) if any command fails • set –u error raised if variable accessed and not declared • set –x echo every command (better than set –v) • set –C does not clobber redirected files. • Can “set” by using set, shebang or bash

  10. Good habits • Use declarations like program code • declare –a • declare –ror readonly • declare –i • declare –x or export • Combine where appropriate • function • local

  11. Good habits • Use bash built-ins where appropriate • Use trap handlers • To cleanup after yourself • To perform extra DEBUGing • Use “\” to break up large lines in your BASH scripts. • Have a simple prompt that includes only the essentials. • unset variables no longer in use. • Use [[ ]] and (( )) where appropriate

  12. Good habits • Bash is evolving - never stop learning!

  13. Bad Habits • Setting TERM – let it be discovered where possible • Setting STTY ERASE - Set your terminal client properly • Overly complicated prompts - we don’t need to know the time. • Use $() instead of ticks ` `

  14. Ugly Habits • .profile .bash_profile .bashrc use • Sourcing oraenvon login • Hardcoding ORACLE_BASE or ORACLE_HOME • Hardcoding PATH, LD_LIBRARY_PATH, CLASSPATH, LIBPATH etc with references to Oracle Homes • Setting ORA_NLS parameters • Alternatives: • Write a script to quickly discover, set, ask for your Oracle Home. • Looping and shifting through $[1..9] instead of getopts

  15. Oft forgotten built-ins • cd – to revert back to flip back to the old directory • eval go Noons! • let do arithmetic the easy way • printf echo with more control

  16. More Information • man bash • Advanced Bash Scripting Guide: http://tldp.org/LDP/abs/html/ • Gnu BASH source code:http://www.gnu.org/s/bash/ • Sample Code:Check Google • Learn SSH • Learn VIM

More Related