\documentclass[10pt]{ictlabtest} \usepackage{rcs} \RCS $Revision: 1.0 $ %\usepackage[screen,margin=4mm,centering]{geometry} %\usepackage{calc,acro,alltt,key,xr,nick,color,multicol} \usepackage{xr,color,alltt} %\geometry{left=10mm, right=10mm} \externaldocument[lt-]% {../../linux_training-plus-config-files-ossi/build/masterfile} \usepackage[pdfpagemode=None,pdfauthor={Nick Urbanik}]{hyperref} \newcommand*{\labTitle}{Quiz 5: Shell Programming} \renewcommand*{\subject}{Operating Systems and Systems Integration} \providecommand*{\RPM}{\acro{RPM}\xspace} \providecommand*{\CD}{\acro{CD}\xspace} %\setlength{\paperwidth}{260mm} %\setlength{\paperheight}{310mm} \makeatletter \renewcommand\theenumii{\@Alph\c@enumii} \makeatother %\newcommand*{\margin}{5mm} %\renewcommand*{\slideleftmargin}{\margin} %\renewcommand*{\sliderightmargin}{\margin} %\renewcommand*{\slidetopmargin}{\margin} %\renewcommand*{\slidetopmargin}{\margin} %\renewcommand*{\slidebottommargin}{\margin} %\renewcommand*{\slidetopmargin}{0pt} %\renewcommand*{\slidebottommargin}{-50pt} % Do not set paperwidth or paperheight. %\setlength{\slidewidth}{297mm-2\margin} %\setlength{\slideheight}{210mm-2\margin} %\setlength{\slideheight}{210mm} %\slideframe[]{none} %\setlength{\slideframesep}{0pt} %\slidesmag{2} %\setcounter{finalcolumnbadness}{10000} %\setcounter{columnbadness}{10000} \definecolor{light-blue}{rgb}{0.4,0.4,1} \newcommand*{\gl}[1]{\textcolor{light-blue}{#1}} % good link \newcommand*{\ex}[1]{\textcolor{green}{#1}} % executable file \newcommand*{\bl}[1]{\colorbox{red}{\textcolor{white}{\textbf{#1}}}} % bad link \begin{document} %% \raggedright %% \pagestyle{empty} %% %\Large %% %\tableofcontents %% %\begin{slide} %% \begin{center} %% \par\vspace*{\fill}\par %% \begin{minipage}[c]{0.99\linewidth} %% \centering {\Huge\sffamily\bfseries Any marks not recognised by %% the Optical Mark Recognition (OMR) machine will get ZERO marks %% \par\vspace*{0.1\textheight}\par %% Correct mistakes with an eraser, correction pen or white tape; it is %% not enough to put a cross through the circle %% \par\vspace*{0.1\textheight}\par %% Errors in student number get ZERO marks} %% \end{minipage} %% \par\vspace*{\fill}\par %% \end{center} %% \clearpage %% %\par\vspace*{-15mm}\par %% \begin{center} %% \bfseries %% {\Large Operating Systems and Systems Integration \ Quick Quiz 3} %% \end{center} \textbf{Do not refer to any printed material.\\ No talking or discussion is allowed until the answer sheets are all collected.} %\extraslideheight{0pt} %\enlargethispage*{2\baselineskip} %\large% %\begin{multicols}{2} %\setcounter{columnbadness}{10000} %\setcounter{unbalance}{2} \paragraph{Review:} \begin{enumerate} \item It is necessary to quote the \emph{parentheses} `\texttt{(\ldots)}' in the following shell command because: \begin{alltt} $ \textbf{echo \bs(3 + 4\bs) \bs* 5} \end{alltt} \begin{enumerate} \item The shell will try to start a subshell \item The \emph{precedence} will be wrong, i.e., addition will not be done \emph{before} multiplication \item The shell will cause a sementation fault \item The shell will terminate with a \emph{divide by zero} exception \item The shell will expand into a list of files otherwise \end{enumerate} \item Which of the following will cause a shell variable \texttt{x} to be defined with the value 10? \begin{enumerate} \item \begin{alltt} $ \textbf{$x=10} \end{alltt} \item \begin{alltt} $ \textbf{$x=$\{10\}} \end{alltt}%$ \item \begin{alltt} $ \textbf{$x = 10} \end{alltt} \item \begin{alltt} $ \textbf{x = 10} \end{alltt}%$ \item \begin{alltt} $ \textbf{x=10} \end{alltt}%$ \end{enumerate} \item A shell script \texttt{script.sh} is executed like this, and the output is shown: \begin{alltt} $ \textbf{script.sh 1 2 3 4 5 6} parameters are 1 2 3 \end{alltt}%$ The first line of the file \texttt{script.sh} is \texttt{\#!~/bin/sh} \ The second line could be: \begin{enumerate} \item \begin{alltt} $ \textbf{parameters are $1 $2 $3} \end{alltt} \item \begin{alltt} $ \textbf{echo parameters are $0 $1 $2} \end{alltt} \item \begin{alltt} $ \textbf{echo parameters are $# $1 $2} \end{alltt} \item \begin{alltt} $ \textbf{echo parameters are $param1 $param2 $param3} \end{alltt} \item \begin{alltt} $ \textbf{echo parameters are $1 $2 $3} \end{alltt} \end{enumerate} %% \item the directory \texttt{/proc} contains information that is: %% \begin{enumerate} %% \item dynamic information about the OS and hardware %% \item a type of relational database; SQL is always used to query it %% \item a list of network \textbf{proc}ters %% \item is unreadable except by the OS kernel %% \item contains entirely static data that is fixed when the computer %% boots %% \end{enumerate} \end{enumerate} \vspace*{-5mm} \paragraph{Preparation:} \begin{enumerate} \setcounter{enumi}{3} \item In the shell, \texttt{while} loops: \begin{enumerate} \item are not supported; we use \texttt{for} loops instead \item used with the keywords \texttt{do}\ldots\,\texttt{done} \item used with the keywords \texttt{do}\ldots\,\texttt{elihw} \item used with braces, as in C and Java \item used with the keywords \texttt{do}\ldots\,\texttt{fi} \end{enumerate} \item Functions in the shell: \begin{enumerate} \item are not \emph{actual} functions, but are separate shell scripts that are loaded at run time \item are not supported in version~2.x of Bash; \item are less useful that in other programming languages \item Cannot accept function parameters \item are not used as much as \emph{shell objects} \end{enumerate} \end{enumerate} %\end{multicols} %\end{slide} \end{document}