Lab 1 Exercise 1
You cannot submit for this problem because the homework's deadline is due.
Ex1. Scripting Web Server
Related Topics: Linux.
Jin decides to develop his personal website and implement a convenient shell script to automate command line tasks. These tasks include:
- Create: create the working directory of the database and webserver, and initialize the database;
- Dump: dump the data in the database into the webserver;
- List: list all the files stored in the webserver;
- Display: display the data in the webserver;
- Destroy: remove the working directory of database and webserver.
He has already implemented the skeleton of ex1.sh
, but he forgets to add some basic commands. There are 5 of such lines in the script that are marked as TODO
comments:
# TODO: Replace this line with a linux command line.
Please help him finish this script by replacing the TODO
s with a Linux command line you learned from lecture.
Create a directory named
sql/
.Copy the file
sql/database.txt
to the directorywebserver/
List all files in directory
webserver/
.Display
webserver/database.txt
instdout
.Remove the
webserver/
andsql/
directories.
Testing
To test the script, please first make it executable by running:
chmod +x ./ex1.sh
Then, you can test the script by running the following commands and observe the results.
./ex1.sh create
./ex1.sh dump
./ex1.sh list
./ex1.sh display
./ex1.sh destroy
Limits
1s, 32MiB