Dec 1

Below is the code to remake the rm command. I remade it so I could send everything i delete to a trashbin. It sends it to your home/.Trashbin. If the directory isnt there, it makes it for you. After that it tests to see if there are any arguments after the command, and if there are 0 it sends back a message. If there are arguments it continues. If the second argument is the -r flag then it send everything after the flag to the trashbin, no matter what. If there isnt the -r present then it only sends files to the trashbin, and if it finds out you tried to delete a directory, it sends back an error. This was made in a bourne-again shell.

Thanks!

Checkout the code below. Read the rest of this entry »

Nov 19

Hey all, this is a guessing game I have written for my operating systems class. It was written for a bash (bourne again shell) unix operating system.

It uses a simple while loop with if loops nested in it to see if the guessed number is higher or lower than the random number.

#!/bin/sh
#gueessing game
biggest=50
guess=0
guesses=0
number=$(( $$ % $biggest ))
while [ $guess -ne $number ] ; do
echo -n "Guess? " ; read guess
if [ "$guess" -lt $number ] ; then
echo "... bigger!"
elif [ "$guess" -gt $number ] ; then
echo "... smaller!"
fi
guesses=$(( $guesses + 1 ))
done
echo "Right!! Guessed $number in $guesses guesses."
exit 0

Nov 14

The following is a school project I did in my technical communications class. Enjoy!

Replacing a flat tire

Introduction

Replacing a flat tire requires only a few essentials: a spare tire, a jack, a tire iron, and a wheel chock (or large rock). Because flat tires are so common and can happen at any time, every driver should know how to replace a tire with a spare. Although it can be daunting the first time you attempt it, replacing a tire is not very difficult. Almost anyone can do it in under 15 minutes, which is less time than it usually takes for assistance to arrive. After reading this set of instructions, you will know how to safely and correctly replace a tire on your own.

Directions

1. Pull off the road, turn off the engine, and turn on the hazard lights.

2. Put the car in park on level ground and apply the parking brake.

Note: If you drive a manual transmission car, you should put it in gear.

3. Place a wheel chock or a large rock behind (if facing uphill) or in front of (if facing downhill) the diagonally opposing wheel to prevent the car from rolling.

Note: This should be done even on a slight incline.

4. Get out the spare tire, a lug nut wrench (tire iron), and a car jack.

Note: To avoid bruised knuckles, you should pull rather than push when removing lug nuts.

Note: Do the following before jacking up the car.

5. Remove the lug nut by placing one end of the tire iron over a lug nut.

Note: The loosening of the lug nuts should be completed in a star pattern, first loosening one a few turns and then loosening the one opposite.

6. Turn the tire iron counter clockwise to loosen the lug nut.

7. Work across the tire until all the lug nuts are loose and unscrewed.

Warning: Cars can slip off jacks. Being extremely careful is very important. You should never get under a car with only a tire changing jack holding it up.

8. Move the jack underneath the car. Read the rest of this entry »