Sponsored Content
Top Forums Shell Programming and Scripting Unix Scripting Question (Homework) Post 302385166 by pitdark on Thursday 7th of January 2010 08:09:27 AM
Old 01-07-2010
Unix Scripting Question (Homework)

Hello im currently taking up Operating Systems and we're on unix ryt now. we have to make a script and here are the requirements.. can someone please help me. I would reli appreciate it.. because i dont reli know how to make scripts yet.

Name of script : parkingcharge.sh
Create a script that computes for the total parking charge of a customer. The following information are to be collected as inputs from the standard input :
Plate number (format : 7 characters, the first 3 are characters from ato z followed by a dash followed by a 3 digit number; i.e. : XXX-123)
Time in (format : military time; i.e. 1500 => 3 PM)
Time out (format : military time; i.e. 1900 => 7 PM)
Type of vehicle : can either be the following characeters: L, U or H which stands for Light vehicle, Utility vehicle or heavy vehicle respectively.
The parking lot operates starting at 7 AM and closes at 11:30 PM. The rates of the parking lot is as follows:
Standard parking fee (minimum of 2 hours) - 50 pesos
Succeeding hour or less in excess of 2 hours for :
Light vehicles - 5 pesos
Utility vehicles - 15 pesos
Heavy vehicles - 25 pesos
Futhermore, the maximum parking charge for the following vehicles applies:
Light vehicles - 100 pesos
Utility vehicles - 150 pesos
Heavy vehicles - 250 pesos
The script should be able to validate whether the time in and time out values are VALID inputs based on the value that is entered (time out > time in). Other validations are not to be filtered by the script. The output of the script is the parking charge of the vehicle and its details.
Sample run:
$ parkingcharge.sh
Please enter the plate number (i.e. : AAE-775) : XNY-123
Please enter the type of vehicle (L/U/H) : U
Please enter the time the vehicle entered the parking lot : 0845
Please enter the time the vehicle entered the parking lot : 1915
The vehicle with plate number XNY-123 was parked for 10 hours and 30 minutes. The parking charge for the vehicle is 150 pesos
Try again? : N
Sample run:
$ parkingcharge.sh
Please enter the plate number (i.e. : AAE-775) : GMA-111
Please enter the type of vehicle (L/U/H) : L
Please enter the time the vehicle entered the parking lot : 1245
Please enter the time the vehicle entered the parking lot : 1315
The vehicle with plate number XNY-123 was parked for 0 hours and 30 minutes. The parking charge for the vehicle is 50 pesos
Try again? : N
Note: Make sure the program keeps on repeating until the user enters ‘N' to quit the program.
Hint : You can use the following commands/control structure to complete your script : expr, if, test, for
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

another scripting question

I am writing a script that will identify the oldest file in a directory. Here's the syntax: #!/bin/ksh cd directory chmod 777 * ls -r -1t > file1 sed -n -e "1P" < file1 > file2 So my problem is, now I have file2, which contains the name of the oldest file in the directory. How do I use,... (1 Reply)
Discussion started by: kristy
1 Replies

2. Shell Programming and Scripting

another scripting question

Hello I am working on cleaning up permissions on Oracle mountpoints and datafiles in unix. I am looking for a script or a scripting idea to 1st. 1. grep for owner oracle 2. ensure its a directory owned for oracle 3. chmod 750 on the oracle owned directory. 4. grep for oracle files, etc... (3 Replies)
Discussion started by: jigarlakhani
3 Replies

3. Shell Programming and Scripting

Scripting question

Folks; I'm writing a shell script to extract some fields out of a log file & it will run periodically, how can i make it runs starting from where it left of. for example; if the script will do the extract every 2 days, let's say the first run will extract fields until July 25, 2007 @ 11:15:22... (1 Reply)
Discussion started by: moe2266
1 Replies

4. UNIX for Dummies Questions & Answers

Scripting question

folks; I have a script to remove any files that older than 14 days then move any files that younger than 7 days to another directory. but for some reason it doesn't move the files, when i do it manually it works but not through the script. i tried 2 different ways in writing the move part but it... (6 Replies)
Discussion started by: Katkota
6 Replies

5. Programming

Homework question

i just need guidance in this please. people who will argue " homeworks are not allowed" , i just need help not solutions . thanks CEG433/CEG633 - Operating Systems please (1 Reply)
Discussion started by: evantheking
1 Replies

6. Homework & Coursework Questions

Homework question

Hi : I cant understand some subjects on DATABASE Class here i'm in small twon i can't find someone to expalin it it to me How can i get good site to find any tutoring throgh the chat or any way i tried to find tutor in the irea but i failed . my question how to understand the... (1 Reply)
Discussion started by: Scotch
1 Replies

7. Homework & Coursework Questions

Perl Scripting issue - homework

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here is the problem: Lesson 13 OBJ1: OST Class online. Write a script called obj13-1.pl and a library... (2 Replies)
Discussion started by: valhalla
2 Replies

8. UNIX for Dummies Questions & Answers

Question about shell scripting in UNIX

Unix script coding help? i am trying to write a code that will display following menu to user: (A) Add (B) Subtract (C) Multiply (D) Divide (E) Modulus (F) Exponentiation (G) Exit Then ask user for choice (A-F). After taking users choice ask user for two numbers and perform... (0 Replies)
Discussion started by: renegade755
0 Replies

9. Shell Programming and Scripting

Scripting question

hi all, I am writing a script and beginner in shell scripting. I have tried the below script. could you please check and let me know whether the below scirpt is correct. Unix details : HP Unix Input file. cat input.txt | tail -4 HTS40002.W1978.PROM HTS40003.W1978.PROM... (17 Replies)
Discussion started by: arun888
17 Replies

10. UNIX for Beginners Questions & Answers

Scripting Homework, need help

Hi I just started scripting in my Unix class, but can't understand it and have trouble with homework. This is my homework: Dean needs a daily written report of the status of his Unix computer. He wants to obtain certain information about users and processes that are only accessible by executing... (1 Reply)
Discussion started by: arbogastcarl
1 Replies
dtscp(1m)																 dtscp(1m)

NAME
dtscp - DTS control program SYNOPSIS
dtscp NOTES
With the exception of the following subcommands, this command is replaced at Revision 1.1 by the dcecp command. This command may be fully replaced by the dcecp command in a future release of DCE, and may no longer be supported at that time. exit help quit DESCRIPTION
This section describes the commands for the DCE Distributed Time Service (DTS) control program (dtscp). The DTS control program is a com- mand-line interface that enables you to synchronize, adjust, and maintain the system clocks in a distributed network. For a detailed expla- nation of system clock synchronization and management, see the OSF DCE Administration Guide. The DTS control program commands are The advertise command, which configures the DTS server as a global server The change command, which modifies the epoch and sets the local time to a new time The create command, which establishes a DTS entity (a clerk or server) The delete command, which causes DTS to exit on the local node The disable command, which suspends a DTS entity The enable command, which starts a DTS entity The exit command, which ends the dtscp management session and returns you to the system prompt The help command which invokes the dtscp help service. The quit command, which ends the dtscp management session and returns you to the system prompt The set command, which modifies characteristics of a DTS entity The show command, which displays characteristics of a DTS entity The synchronize command, which synchronizes the system clock with the time obtained from DTS servers in the network The unadvertise command, which removes the global server entry The update command, which gradually adjusts the system clock to a new time For more information on any of the above dtscp commands, see the appropriate reference page in this chapter. You can use control program commands from within the control program or from the system prompt. To enter DTS commands from within the con- trol program, first start the control program by entering the dtscp command. For example: $ dtscp dtscp> At this prompt you can enter any control program command; for example: dtscp> show current time To leave the control program and return to the system prompt, enter the exit command. To enter DTS commands from the system prompt (interactively or in a command procedure) enter the dtscp command with an internal command of the control program as the first argument. The control program executes the command without displaying the control program prompt. For example, you can enter the synchronize command as follows: $ dtscp synchronize Some dtscp commands have optional arguments or attributes; there may also be optional variables for the arguments and attributes. See the following sample command: dtscp> update time 1990-08-03-05:45:28.000+01:00I00.500 / / / Command [Argument] Variable -------- [Attribute] Abbreviations You can enter as few as three characters for each DTS command or argument; DTS commands and arguments are unique for three characters or more. For example, rather than entering the command enable set clock true, you can enter the following abbreviated command: dtscp> ena set clo tru Attributes The dtscp set and show commands have several attributes--pieces or sets of data associated with them. The attribute groups are categorized as follows: Set or show the entity's operation. Show the number of occurrences of an event since the entity was enabled. Show the current state of the entity. (The DTS entity has four status attributes.) Show the global servers known by this DTS entity. Show the local servers known by this DTS entity. Individual attributes within each of the previously listed groups are described in the reference pages for the set and show commands. The show command also allows you to specify attribute groups. Time Stamps All responses to commands contain a timestamp. The following example shows a typical DTS time display: 1993-03-16-14:29:47.52000-05:00I000.003 The timestamp uses the DTS format that is explained in Chapter 15 of the OSF DCE Administration Guide--Core Components. In this example, the year is 1993, the day is March 16, and the time is 14 hours, 29 minutes, and 47.52 seconds. A negative Time Differential Factor (TDF) of 5 hours and an inaccuracy of 3 milliseconds are included in the timestamp. An inaccuracy value of I----- indicates an infinite inaccu- racy. This value appears in time displays before a node's initial synchronization or after you enter the change command without specifying an inaccuracy value. RELATED INFORMATION
Commands: advertise, change, create, delete, disable, enable, exit, help, set, show, synchronize, quit, unadvertise, update Books: OSF DCE Administration Guide dtscp(1m)
All times are GMT -4. The time now is 03:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy