Register
It is currently Sat Oct 25, 2014 10:01 am

ToMaS - Transportation Managment System


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun May 20, 2012 7:18 pm   

Joined: Sun May 20, 2012 6:32 pm
Posts: 1
I'm working on this as a proof of concept that a unix based system could take the place of the AS400 system currently in use by most trucking companies. I am nowhere close to being finished, and it has not really been tested. If you notice any places that I messed up or have any suggestions to make this better please let me know.
Thanks.
Paul


Code:
#!/bin/bash
# ToMaS
# Created by Paul "Mad Hatter" Hartman
# tomas.sh
# This part of the program will simply welcome you to the program.

echo  "Welcome to ToMaS"
read -p "Press Enter To Continue"
# need to clear the screen now

clear

# What would you like to do?
# To add additional choices to the menu, add the options in the first and second menu sections and add an additional
# loop to the nest. The change the coice init variable and init test variable to a number 1 higher then the number
# of choices that you have entered. ie If you have 6 choices then the init variable and test variable should be 7.

# Declare variable choice and assign value 4
choice=5
# Print to stdout
echo "1. Red Tag Equipment"
echo "2. Green Tag Equipment"
echo "3. Equipment Status"
echo "4. Add New Equipment To Fleet"
echo -n "Please make a selection. [1-4]? "
# Loop while the variable choice is equal 4
# bash while loop
while [ $choice -eq 5 ]; do

# read user input
read choice
# bash nested if/else
if [ $choice -eq 1 ] ; then
#choice 1
        bash ./redtag.sh

else                   
# Choice 2
        if [ $choice -eq 2 ] ; then
                 bash ./green.sh
        else
# Choice 3         
                if [ $choice -eq 3 ] ; then
                        echo "The Equipment Status Program Should run Here"
                else
         
          if [ $choice -eq 4 ] ; then
         bash ./add.sh
          else
         clear   
         echo "Please make a choice between 1-3 !"
         echo "1. Red Tag Equipment"
         echo "2. Green Tag Equipment"
         echo "3. Equipment Status"
         echo "Please make a selection. [1-4]? "
         echo -n "Please make a selection. [1,2 or 3] "   
         choice=5
# I keep getting an unexpected token at line 63 near "done" error. *** FIXED *** Was missing a extra fi. one is needed for each nested if loop.
         
         
            
          fi
      fi
   fi
    fi   
done


Code:
#! /bin/bash
# Red Tagging program
# redtag.sh
# Written by Paul Hartman
# this program is intended to be called by the launcher program.
# It's purpose is to redtag trucks. To do this it will pull the truck off the ready list and
# place it on the red tag list.

# to start off lets clear the screen
clear

# Now lets initialize the variables that we will be using.

greenlist="../data/readylist.csv"
redtag="../data/redtaglist.csv"
#data=0   # this may be used at a later time.

# Ok. Now on with the program.
# here is the question and answer phase

echo "Red Tag Equipment"
echo ""
echo ""
echo "Truck Number: "
read trucknumber
echo "Mileage: "
read mileage
# echo "Please discribe the problem: " # These two lines we will not be using for a while but it is likely
# echo problem                         # that we will need them later on.
echo "Is this truck usable and safe in its current condition? {y/n} "
read safe
echo "Where is this truck now? "
read location

# ok now for the meat of the program
# lets search the ready list for the truck number that we want to play with.
search1= grep -c $trucknumber $greenlist

if $search1=0
  echo "That truck can not be found on the ready line. Please check the truck number and try again."
  read -p "Press enter to continue."
  clear
else
  if $search1=1;
    sed -n /$trucknumber/d
    echo "{$trucknumber}, {$mileage}, {$location}, {$safe}" >> $redtag
    errorcheck= grep -c $trucknumber $redtag
      if $errorcheck=0
        echo "Whoop! There is a problem writing redtag data to the redtag file."
      if $errorcheck={ <1 }
        echo "Uh Oh! There seems to be more then one {$trucknumber} in the redtag file."
  else
    clear
    exec bash ./tomas.sh
fi



Code:
#!/bin/bash
#tomas greentag subprogram
# green.sh
# WRITTEN BY PAUL HARTMAN

# This subprogram will green tag a red tagged truck  and mark it as availible
#Each truck should have its own file and there should be a csv file showing the current status of all of the trucks in the system
# This might be easier to write as a bash script rather then a python program.
# It has now been switched to bash.
#Nessasary fields

# truck number
# discription of the problem fixed
# Ask if the truck is ready for use
# Where is the truck now?
# after entering the requested information the program should save it to the trucks file and change the trucks status to green.

# This line is to initilize the truck csv file.
csv="../data/readylist.csv"

#Pulled this example from http://linuxconfig.org/Bash_scripting_Tutorial
#I think that I will use it for checking to see if the files that I need are present
#Please note the spacing inside the [ and ] brackets! Without the spaces, it won't work!

# #!/bin/bash
# directory="./BashScripting"
#
# # bash check if directory exists
# if [ -d $directory ]; then
#    echo "Directory exists"
# else
#    echo "Directory does not exists"
# fi
##

# This is the file checking subroutine
thefile ="./BashScripting"

# bash check if file exists
if [ -f $thefile ]; then
   # Here is the actual program
  echo "Green Tag Truck"
  echo "WHAT IS THE TRUCK NUMBER?"
  read trucknumber
  echo "Mileage?"
  read mileage
  echo "PLEASE DISCRIBE ALL PROBLEMS YOU HAVE FIXED."
  read problem
  echo "IS THIS TRUCK SAFE AND READY FOR USE? (y,n)"
  read safe
  echo "WHERE IS THIS TRUCK NOW?"
  read location
else
  echo 'File "./data/readylist.csv" does not exist. Please contact IT immediatly'
   

# send to a csv file  the previose information in the following order trucknumber,safe, location  and replace the information in it
# This part is only printing out the commas at this point. MAY HAVE BEEN FIXED USING THE BRACKETS.
# THE BRACKETS ARE SUPPOSED TO PROTECT THE VARIABLE WHILE PRINTING TO THE SCREEN
echo "${trucknumber}, ${milage}, ${safe}, ${location}" >> ./data/readylist.csv



# Now if I have thought this through properly that should be the end of the program.
# I should have it return to the launcher program now.
#but first lets clear the screen.
clear

#lets see if the launcher program even exists before trying it.
if [ -f ./tomas.sh ]; then
  exec bash ./tomas.sh
else
  echo "TERMINAL ERROR! LAUNCHER PROGRAM, tomas.sh IS MISSING. CONTACT IT"
  read ""
  clear
fi





Code:
#!/bin/bash
# Add Equipment Program
# Written by Paul Hartman
# add.sh
# This program is designed to add equipment to the ToMaS data files. It will automaticly place added equipment on the ready line.

# Here are the variables
greenlist= ../data/readylist.csv
safe="y"

clear
echo "ADD EQUIPMENT"
echo ""
echo ""
read -p "Unit Number: " unit
#read -p "VIN: " vin
#read -p "Make: " make
#read -p "Modle: " model
#read -p "Year: " year
read -p "Mileage" mileage
read -p "Current locatation: " location

# This section should add the data record to the readylist
echo "{$unit}, {$mileage}, {$location}, {$safe}">>$greenlist

# From here I need to setup another file to handle the trucks repair history. Having a load history and driver
# history included in that file would be helpful as well, when and if this system gets to that point.

# This will create the file for the new unit
touch ./data/equipment/$unit
equipment=./data/equipment/$unit
# Now we add the initial data to the file we just created.

echo $unit >> $equipment
echo $vin >> $equipment
echo $make >> $equipment
echo $model >> $equipment
echo $year >> $equipment
echo $mileage >> $equipment

bash ./tomas.sh
fi
done




Edited to add a tarball containing my working files.


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 PostPosted: Thu Jun 28, 2012 2:58 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
There are many non-bash(1) syntaxes.
Please, don't try to guess the syntax.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP