Shell Scripting Pt. 2

Shell Scripting Pt. 2

Reading from Files and Databases

  • Files
    • List of commands (sed, for example)
    • The “read” command (cat file and pipe to while loop
  • Databases
    • MySQL .my.cnf file, Postgres .pgpass (400 and 600)
    • Save path to variable (which mysql)
    • <<EOF to run/chain queries
    • Insert values with arguments

GUI Menus

  • dialog

    • msgbox: Short message followed by OK button
    • yesno: msgbox with Yes/No options – Use status option to proceed
    • textbox: Presents data (disk usage, memory info, message/e-mail)
    • menu: Create a menu with title, selector, and text
  • kdialog

    • For KDE environment
    • Not as flexible
    • Similar widgets as dialog
  • zenity

    • Gnome environment
    • Installed out of the box on Fedora
    • Similar to kdialog, more aesthetically pleasing (personal preference)
  • Why GUI Menus

    • Installer/Setup
    • Reporting
    • Analytics
    • Ease someone (dev/QA) into sysadmin

E-mail

  • mailx
    • Send messages through SMTP
    • Provide complete information via arguments
    • Pipe message to mailx command
    • Simple notification system for successful/failed script
3 Likes