Scripting

From Systerserver

Jump to: navigation, search

there is a fine line between a bash command, unix program, scripting and programming!

Contents

console

  • the screen and keyboard which allows access and control of the server
  • terminal emulator, a program that substitutes for a computer console or computer terminal
  • virtual console, a user interface for multiple computer consoles on one device
  • The graphical X Window System starts in the seventh virtual console, Alt+F7

terminal emulator

A terminal emulator is a program that emulates a "dumb" video/grpahics terminal within some other display architecture. Though typically synonymous with a command line shell or text terminal, the term 'terminal' covers all remote terminals, including graphical interfaces. A terminal emulator inside a graphical user interface is often called a terminal window.

shell

A shell is a piece of software that provides an interface for users. Traditionally a shell account was a user account on a remote server which gave you to access a unix shell via a command-line interface protocol such as telnet or ssh.

command line interface

A CLI can generally be considered as consisting of syntax and semantics.

Bash

Bash is a free software Unix shell written for the GNU Project. Its name is an acronym which stands for Bourne-again shell.

bash environment

  • HISTTIMEFORMAT='%F %T '
  • export HISTTIMEFORMAT
  • unset HISTTIMEFORMAT
  • or source .bashrc to restore the default
  • HISTCONTROL=ignoreboth (ignorespace:ignoredups)

first things i do on a clean install server:

  • add the following line to the /etc/profile or /home/user/.profile:
  • export HISTCONTROL=ignoredups
  • It varies by shell, but basically the set command is used to define a variable for the current shell.
  • The export command is used to define a variable as one which subshells should inherit.
  • synchronizing the history across multiple sessions:
  • PROMPT_COMMAND="history -a;history -c; history -r;$PROMPT_COMMAND"

profile

  • /etc/profile is the systemwide initialization profile file for all users.
  • /etc/bash.bashrc is the systemwide per-interactive-shell startup file. This file is called from /etc/profile
  • $HOME/.bash_profile is the personal initialization file, executed for login shells. Add PATH settings and other user specific variables to this file.
  • $HOME/.bashrc is the individual per-interactive-shell startup file. Add user specific aliases and functions to this file.

scripting

"Scripts" are distinct from the core code of the application, which is usually written in a different language, and are often created or at least modified by the end-user. Scripts are often interpreted from source code or bytecode, whereas the applications they control are traditionally compiled to native machine code. Scripting languages are nearly always embedded in the applications they control.

sed

sed (stream editor) is a Unix utility which (a) parses text files and (b) implements a programming language which can apply textual transformations to such files. It reads input files line by line (sequentially), applying the operation which has been specified via the command line (or a sed script), and then outputs the line.

awk

gawk (GNU awk)