\documentclass{beamer} %include lhs2TeX.fmt \author{Piyush P Kurur\\ Office no: 224\\ Dept. of Comp. Sci. and Engg.\\ IIT Kanpur} \newcommand{\Token}[2][]{\node(#2#1)[token]{#2};} \newcommand{\Symbol}[2][]{\node(#2#1)[symbol]{#2};} \newcommand{\Point}[1]{\node(#1)[point]{#1};} \usepackage{tikz} \usetikzlibrary{positioning,shapes,chains,fit,shadows} \usetikzlibrary{shapes.symbols} \usetikzlibrary{matrix} \usetikzlibrary{backgrounds} \usetikzlibrary{shapes.geometric} \usepackage{multicol} \usepackage{algorithm2e} \usepackage{pgfkeys} %% \newcommand{\SingleLinkedList}[1]{ %% \foreach \datum/\anchor in {#1} %% \begin{scope} %% \node[rectangle, fill=yellow!30]{#2}; %% \node[rectangle, below, fill=green!30](#1){$\cdot$}; %% \end{scope} %% } %% \newcommand{\Null}{ %% \node[circle, fill=black, minimum size=1em]{}; %% } \pgfkeys {% /tikz/oval/.style={% shape=ellipse, inner sep=1pt, drop shadow, draw = black }, /tikz/redbox/.style={% shape=rectangle,% minimum size=1.5em,% top color = white, % bottom color=red!50!black!50, inner sep=0pt, draw=black }, /tikz/null/.style={% shape=circle, minimum size=0.5em, draw=black, }, /tikz/greybox/.style={ shape=rectangle,% minimum width=7em,% minimum height=1.5em, fill=black!20, inner sep=0pt, draw=black }, /tikz/blackbox/.style={ shape=rectangle,% minimum width=7em,% minimum height=1.5em, fill=black, inner sep=0pt, draw=black }, /tikz/whitebox/.style={ shape=rectangle, minimum width=7em, minimum height=1.5em, draw=black }, /tikz/bluebox/.style={ shape=rectangle, minimum width=7em, minimum height=1.5em, fill=blue!40, draw=black }, /tikz/whitetape/.style={ shape=rectangle, minimum width=4em, minimum height=1.5em, draw=black }, /tikz/bluearr/.style={ ->, line width=0.25em, draw=blue!40 }, /tikz/greenarr/.style={ ->, line width=0.25em, draw=green!40!black!60 } } \newcommand{\arraythree}[4]{ \begin{tikzpicture}[node distance=0] \pgfsetstrokeopacity{#4}; \node[#1](a0#3){#2}; \node[#1, right=of a0#3](a1#3){#2}; \node[#1, right=of a1#3](a1#3){#2}; \end{tikzpicture} } \newcommand{\arraytwo}[4]{ \begin{tikzpicture}[node distance=0] \pgfsetstrokeopacity{#4}; \node[#1](a0#3){#2}; \node[#1,right=of a0#3]{#2}; \end{tikzpicture} } \newcommand{\Array}[0]{ \arraythree{box}{}{a}{1} } \newcommand{\AArray}[0]{% \arraythree{bbox}{\Array}{b}{0.5}} \newcommand{\AAArray}[0]{% \arraytwo{bbbox}{\AArray}{c}{0.25}} \newcommand{\T}[1]{\ensuremath{T\left(#1\right)}} \newcommand{\BigOh}[1]{\ensuremath{O\left(#1\right)}} \title{Fundamentals of Computing: Lecture 37} \date{November 9, 2009} \begin{document} \begin{frame} \maketitle \end{frame} \begin{frame} \frametitle{The Unix system} \begin{tikzpicture} \node[oval,fill=yellow!30]{ \begin{tikzpicture}[node distance=0pt] \node(shell){shell}; \node[oval, fill=yellow!40, below=of shell]{ \begin{tikzpicture} \node(user){user programs}; \node[oval, fill=red!30, below=of user]{ \begin{tikzpicture} \node(kernel){kernel}; \node[oval, fill= red!40, below=of kernel]{hardware}; \end{tikzpicture} }; \end{tikzpicture} }; \end{tikzpicture} }; \end{tikzpicture} \end{frame} \begin{frame} \frametitle{The Shell} \begin{itemize} \pause \item The command processor \pause \item In non-graphical mode is the first that is executed on login. \pause \item Is programmable. \pause \item Collection of shell commands forms a shell program. \end{itemize} \pause \begin{block}{Which shell?} \pause There are many shells available, each slightly different syntax. We will use the |bash| shell. Other common shells are |csh|, |zsh| etc. \end{block} \end{frame} \begin{frame} \frametitle{Simplest shell program} The starting |$| is the prompt. You dont have to type it. \begin{spec} $ programname arg1 arg2 arg2 \end{spec} e.g. \begin{spec} $ echo foo bar biz \end{spec} \end{frame} \begin{frame} \frametitle{Redirecting a file to input and output to file} Remember that every program has three open files, |stdin|, |stdout|, |stderr| \begin{itemize} \item If we write |$ cmd foo| then the |stdout| of |cmd| is the file |foo| and not the monitor. \end{itemize} \begin{spec} $ cat > foo I am redirecting the output of cat to foo. $ cat < foo I am redirecting the output of cat to foo. $ exit \end{spec} \end{frame} \begin{frame} \frametitle{One can also redirect |stderr|} \begin{itemize} \pause \item Redirecting |stderr| to a file |cmd 2>foo| (no space between |2| and |>|) \pause \item Redirecting |stderr| to |stdout| |cmd 2>&1|(no space between |&| and |1|) \end{itemize} \pause \begin{spec} $ gcc badCFile.c # Too much data see in pages $ gcc badCFile 2>&1 | less \end{spec} \pause This also tells us about piping. \begin{spec} $ cmd1 | cmd2 | cmd3 | cmd4 $ \end{spec} \end{frame} \begin{frame} \frametitle{Some useful programs} \begin{itemize} \item |echo| prints its command line arguments \item |less| shows int |stdin| in pages \item |grep pattern| shows only those lines of its stdin that matches the pattern. \end{itemize} \end{frame} \end{document}