[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 110: Undefined array key "cached"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 111: Undefined array key "normal"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 112: Undefined array key "total"
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3391: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3393: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3394: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3395: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
Cabrillo College Linux Classes • View topic - repeated actions scream "script me"

repeated actions scream "script me"

UNIX/Linux Network Administration

repeated actions scream "script me"

Postby Greg Earthman on Tue May 26, 2009 1:46 pm

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)
Greg Earthman
 
Posts: 21
Joined: Tue Nov 04, 2008 9:34 pm

Re: repeated actions scream "script me"

Postby Greg Earthman on Tue May 26, 2009 1:51 pm

I forgot to add that as the file is built, you can then scp it to the next box (vm in our case) to continue adding the output from the next box, and ultimately you should be on a box that will connect to opus, and can scp cis192.opus.cabrillo.edu:lab_file labxx.yourlastname.

I have saved the sripts in a directory in my account on opus, so it is easily accessable from lab to lab since again, connectivity to opus from at least one of the boxes is needed.
Greg Earthman
 
Posts: 21
Joined: Tue Nov 04, 2008 9:34 pm


Return to CIS 192 - Spring 2009

Who is online

Users browsing this forum: No registered users and 0 guests

cron