Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
16
I have attached the instructions. I would need the work to be completed on word doc. I have more files to share but its not allowing me to share it. In order to complete the work I have 13 hours.
This order does not have tags, yet.
Attachments
COSC 4337 Operating Systems Dr. Zhu
Project 1 Creating a Shell Interface
Due Date: 9/26/21 11:59pm
These are the instructions for your first Operating Systems programming project. Recall that the
project is done by group of 2 students. You could submit only one copy with two names.
Problem:
This project consists of modifying a Java program so that it serves as a shell interface that
accepts user commands and then executes each command in a separate process external
to the Java virtual machine.
Even the code is given here in Java, however, you could change it and use C++ with
corresponding changes.
Overview:
A shell interface provides the user with a prompt, after which the user enters the next
command. The example below illustrates the prompt jsh> and the user’s next command:
cat Prog.java. This command displays the file Prog.java on the terminal using the UNIX
cat command.
jsh> cat Prog.java
Perhaps the easiest technique for implementing a shell interface is to have the program
first read what the user enters on the command line (here, cat Prog.java) and then create a
separate external process that performs the command. We create the separate process
using the ProcessBuilder() object, as illustrated in Figure 3.13. In our example, this
separate process is external to the JVM and begins execution when its run() method is
invoked.
COSC 4337 Operating Systems Dr. Zhu
A Java program that provides the basic operations of a command-line shell is supplied in
Figure 3.37. The main() method presents the prompt jsh> for the java shell and waits to
read input from the user. The program is terminated when the user enters <Control><C>.
This project is organized into three parts: 1) creating the external process and executing
the command in that process, 2) modifying the shell to allow changing directories, and 3)
adding a history feature.
1) Creating the external process
The first part of this project is to modify the main() method in Figure 3.37 so that
an external process is created and executes the command specified by the user.
Initially, the command must be parsed into separate parameters and passed to the
constructor for the ProcessBuilder object. For example, if the user enters the
command
jsh> cat Prog.java
COSC 4337 Operating Systems Dr. Zhu
the parameters are (1) cat and (2) Prog.java, and these parameters must be passed
to the ProcessBuilder constructor. Perhaps the easiest strategy for doing this is to
use the constructor with the following signature:
public ProcessBuilder (List<String> command)
A java.util.ArrayList – which implements the java.util.List interface – can be used
in this instance, where the first element of the list is cat and the second element is
Prog.java. This is an especially useful strategy because the number of arguments
passed to UNIX commands may vary (the cat command accepts one argument,
the cp command accepts two, and so forth).
If the user enters an invalid command, the start() method in the ProcessBuilder
class throws an java.io.IOException. If this occurs, your program should output
an appropriate error message and resume waiting for further commands from the
user.
COSC 4337 Operating Systems Dr. Zhu
2) Changing directories
The next task is to modify the program in Figure 3.37 so that it changes
directories. In UNIX systems, we encounter the concept of the current working
directory, which is simply the directory you are currently in. The cd command
allows a user to change current directories. Your shell interface must support this
command. For Example, if the current directory is /usr/tom and the user enters cd
music, the current directory becomes /usr/tom/music. Subsequent commands relate
to this current directory. For example, entering ls will output allt eh files in
/usr/tom/music. The ProcessBuilder class provides the following method for
changing the working directory:
public ProcessBuilder directory(File directory)
When the start() method of a subsequent process is invoked, the new process will
use this as the current working directory. For example, if one process with a
current working directory of /usr/tom invokes the command cd music, subsequent
processes must set their working directors to /usr/tom/music before beginning
execution. It is important to note that your program must first make sure the new
path being specified is a valid directory. If not, your program should output an
appropriate error message.
If the user enters the command cd, change the current working directory to the
user’s home directory. The home directory for the current user can be obtained by
invoking the static getProperty() method in the System class as follows:
System.getProperty(“user.dir”);
3) Adding a history feature
Many UNIX shells provide a history feature that allows users to see the history of
commands they have entered and to rerun a command from that history. The
history includes all commands that have been entered by the user since the shell
was invoked. For example, if the user entered the history command and saw as
output:
0 pwd
1 ls –l
2 cat Prog.java
The history would list pwd as the first command entered, ls –l as the second
command, and so on.
Modify your shell program so that commands are entered into a history. (hint, the
java.util.ArrayList provides a useful data structure for storing these commands).
You program must allow users to rerun commands from their history.
COSC 4337 Operating Systems Dr. Zhu
What to hand in?
• According to the attached report template, please submit a report includes problem
statement, analysis, algorithm design, class prototype (class contract), program
Input/Output, and tested results (analysis your result to see if it is correct).
• The source program files (name your file “project1.java” or “project1.cpp”)
• You could either submit through Blackboard or my email box.
Each Java program should have the following in the beginning:
// Program Name: <The name of your Java program file>
// Programmer: <Your name here>, <ID>
// Assignment Number: <put project number here, e.g. Project #1>
// Purpose: <A short problem description>
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: Modifying A Java Program So That It Serves A Interface or similar questions only at Tutlance.
Related Questions
- Ethernet Applications Trend
- Simnet Excel Exam - Creating And Editing Workbooks
- Human Benchmark Games Using Javafx
- Minesweeper Alpha Project (Java)
- Minesweeper Alpha Project (Java)
- Java 2D Array Use Union Find To Check If 2D System Percolates
- An Assignment Help Is Required, Modern Algorithm Design
- Short Prolog Programming Exercise
- 9-2 Final Project Submission: Collection Manager Program
- C++ 5 State Single Threaded Processor
- Tableau Homework Help Data Connectivity
- Malware Protection Procedure Guide
- Go Enigma A Statistical Attack You Have Recovered The Ciphertext Found In The File Ct.txt
- Jsoup Wikipedia Parsing Assignment
- Demonstrate The Ability To Refactor Code, Add Data Members (Fields) To Classes, And Create And Interact With Objects.
- Typescript Transformation Matrices
- Spring 2021 Excel Assignment!
- Excel Bill Of Materials Needed
- This Homework Is Intended To Review And Extend Your Knowledge Of Classes In Python.
- Coursework Sheet With Binary Numbers And Assembly
- Python Help Using Jupyter Notebook
- Security Plan For A Beginner Cyber Security Certificate Class
- I Need The Proper Code For Python For This Assignment
- Lab Completion For Class
- System Analysis And Project Management Assignment
- Excel Modeling For Commercial Real Estate
- Music And Its Effects On The Brain, The History Of Reggae Music In Africa Musical Style History After World War Ii.
- Python Bitgen With Proxy, Over Threads
- Data Analysis Of How Chicago Covid-19 Cases And Deaths Impact On Chicago Crime Rate
- Business Intelligent (Bi) Analyst
- Excel Homework One And Two Variable Data Tables
- Applying A Creational Pattern To An Python Project
- Mapping And Monitoring With Nmap And Wireshark Assessment
- Excel Analyzing Data Into A Word Document
- Python Programming Assignment .
- C++ Avl Tree And Binary Max Heap
- Statistical Computer In R And Python
- Design A Four Page Webpage Assignment
- Naiive Bayes Classifier Programming Assignment
- Nanosatellite-5G Integration In The Millimeter Wave Domain
- C++ Backtracking Puzzle, See Attached File For Instructions
- Everything Is In The File!!!!!!
- C++ Project On Graphs With 6 Major Parts To Be Completed
- Python Programming- 5 Questions In Total
- Create A Subroutine To Print A 0-Terminated String
- Computer Science Computer Science
- Writing An Original Assembly Language Program
- C Programming Help Tic Tac Toe Game
- Java Homework About Java Hashmap Assignment Just Write Me
- User Interface (Ui) And User Experience (Ux) Project #2 Theme: Form With Conditional Rendering