Lab 1 Exercise 1

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 TODOs with a Linux command line you learned from lecture.

  1. Create a directory named sql/.

  2. Copy the file sql/database.txt to the directory webserver/

  3. List all files in directory webserver/.

  4. Display webserver/database.txt in stdout.

  5. Remove the webserver/ and sql/ 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

Lab 1

Not Claimed
Status
Finished
Problems
3
Open Since
2023-05-12 18:00
DDL
2023-05-18 23:59
Extension
72.0 hour(s)