Skip to content
Chris Taylor edited this page Sep 15, 2020 · 11 revisions

Scripts

In this project our team was tasked to create some sort of a script that meets the following criteria:

  • The script must be executable from any directory it is ran in.
  • The script must print out the top level directory that it is in.
  • The output must be printed onto a browser (using html)

The script we created was written in in bash and was saved into a .sh file.

Bash Script

When creating the our first bash script, we had a simple script that outputted the html with no css
After getting the output that we wanted to see, we tried to make it look a little better!
We found that after styling the script, we lost all but the first file read in, and not wanting to deal with bash, we switched back to out earlier version.


bash print outputted files
styled html
Code for simple working version
Code for styled version (not working)

Python Script

Since it's not fun to do anything even remotely complicated in bash, we decided to recreate the script in python to add more advanced features.

Generating the html turned out to be much easier for us to do in python, and the newer script incorporates even more features.

myList.py generates an html file that is stored in /tmp (to be deleted on reboot on most systems) that contains the results from ls, as well as buttons to take you to all of the files, and the results of the tree command if it is installed.

Here's the updated version in use:

running the script

script output
Code for python version