preparing the turnin for the labs involves many steps that are repeated, so I started to put them to simple scripts.
an example is the boilerplate script I mentio0ned in another post.
when formatting the output of the commands, I try to seperate it with blank lines and a row of stars. initially i did that by using at the command line:
echo "output of some command"
echo >> lab_file
echo "**************************************************" >> lab_file
echo "**************************************************" >> lab_file
echo >> lab_file
cat output of command here >> lab_file
echo >> lab_file
echo"*********************************************************" >> lab_file
this quickly became repetitive, so I made a script called stars.sh which was:
#!/bin/bash
echo "***********************************************************"
which took care of writing the line of stars
then I made start2.sh which started with a blank line followed by two lines of stars followed by a blank line.
this changed the action needed to :
./stars2 >> lab_file
echo " output of cat some config file" >> lab_file
echo
./stars.sh >> lab_file
echo
I quickly saw that the stars.sh should include the two blank lines as well so did that.
I have shortened that by making a script called headers.sh which will write the header and then also put in the stars, and also output the config file and finish up by putting two rows of stars at bottom.
#!/bin/bash
./stars2.sh
echo "output of $1"
./start.sh
cat $1
./stars
and now the output can be generated by using:
headers.sh /etc/resolv.conf >> lab_file
********************************************************************
********************************************************************
output of cat /etc/resolv.conf
**********************************************
nameserver 192.168.2.1
**********************************************
would now produce a nicely formatted output of the /etc/resolv.conf as above with only a short command line and appends it to the lab_file.
this is really a q&d script (q&d is quick and dirty, and in this context q&d means that there is no handling of errors in the script. You are the error checker, so you need to validate the input yourself)