-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScripting.tex
More file actions
75 lines (60 loc) · 2.22 KB
/
Copy pathScripting.tex
File metadata and controls
75 lines (60 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
\item Script 1 : pdflatex\verb"_"cleanup.sh
\begin{verbatim}
# if no argument is specified removes .aux and .log files from the
# current directory
# if document name is provided, removes only .aux and .log files
# for that document
#
# usage: pdflatex_cleanup.sh [document_name]
#
# @author: Alec Parfitt
if [ $# -eq 0 ]; then
rm -f *.aux *.log
else
rm -f $1.aux $1.log
fi
\end{verbatim}
\item Script 2 : userlog.sh
\begin{verbatim}
# prints the bash history of specified user to a file
# [username]-[date].log in the current directory
# also prints the last login of that user to [username]-login.log
#
# Assumes that home directories are in /home/[username]
#
# requires root privileges if you want to run it on another user's
# account
#
# usage: sudo userlog.sh [username]
#
# @author: Alec Parfitt
# check for argument
if [ $# -eq 0 ]; then
echo "No argument supplied"
echo "Usage: userlog.sh username"
exit 1
fi
# check if user exists
if ! id -u "$1" >/dev/null 2>&1; then
echo "User does not exist"
exit 1
fi
# read user bash history from home/user/.bash_history
cat /home/"$1"/.bash_history > ./$1-"$(date)".txt
# get last login date and time and append it to the log
last -a "$1" | head -n 1 > ./$1-login.log
\end{verbatim}
\item Scripts 3 and 4 : animation.sh and adventure.sh
\verb"https://youtu.be/zU6PQEYDpXM"
In the video, I actually demo all scripts created for this assignment. If you can't make it out,
you may have to manually increase the quality. It should be available in 1080p.
The animation script will bouce supplied text around the screen, or just an 'O' if nothing is given to it.
The adventure script is a simple text adventure game, not everything is perfect but it work well enough.
I will include the .sh files for all of these in the homework submission if possible, if not I will make
public github repo temporarily for the assignment.
\end{enumerate}
\end{document}