**********************************************Code************************************
class ShellApplication:
def __init__(self):
# From here we are taking the data from user and based on the command given we are calling functions
while True:
print "----------------------------------"
print "1-Command\n2-stop"
ch = input()
if ch == 1:
print "Enter command:"
command = raw_input().split(" ")
print "*****************************"
if command[0] == "echo":
# If first word is echo then we are calling display_text function
self.display_text(command)
elif command[0] == "average":
# If first word is average then we are calling print_average function
self.print_average(command)
elif command[0] == "strstr":
# If first word is strstr then we are calling find_index
self.find_index(command)
elif command[0] == "script":
# If first word is script then we are calling read_from_file function
self.read_from_file(command)
else:
print "Invalid Command"
elif ch == 2:
break
else:
print "Choose correctly"
@staticmethod
def display_text(commands):
# Here we are joining the text given and printing it
text = ' '.join(commands[1:])
print text
@staticmethod
def print_average(commands):
# Here we are converting the given string to float if any error occurs displaying the text else printing avg
try:
count = 0
sum = 0
for num in commands[1:]:
sum += float(num)
count += 1
print sum / count
except:
print "ERROR: usage: average <number> <number> .. <number>"
@staticmethod
def find_index(commands):
# This function will find str2 in str1
if len(commands[1:]) == 2:
# If length is 2 then we will find the str2 in str1 else we will show the error message
find_str = commands[2].replace("\n", "")
# First here we are checking whether str2 is in str1 or not if it is there then we are printing index
if find_str in commands[1]:
print commands[1].index(find_str)
else:
print "String is not found!!"
else:
print "ERROR: usage: strstr <arg0> <arg1>"
def read_from_file(self, commands):
# Here we are reading the text from file line by line and we are processing that based on the given text
file_name = commands[1].replace("\n", "")
with open(file_name) as fd:
content = fd.readlines()
for line in content:
split_line = line.split(' ')
if split_line[0] == "echo":
# If first word is echo then we are calling display_text function
self.display_text(split_line)
elif split_line[0] == "average":
# If first word is average then we are calling print_average function
self.print_average(split_line)
elif split_line[0] == "strstr":
# If first word is strstr then we are calling find_index
self.find_index(split_line)
elif split_line[0] == "script":
# If first word is script then we are calling read_from_file function
self.read_from_file(split_line)
else:
print "Invalid Command Line Arguments"
obj = ShellApplication()
*************************************Code Screens********************************

![@staticmethod def find index(commands) 50 52 53 54 # This function will find str2 in str1 if len (commands [1:])2: # If lengt](http://img.homeworklib.com/questions/42f4b740-7f2e-11eb-b75d-059586ed3d85.png?x-oss-process=image/resize,w_560)
*************************************Output Screens********************************



PYTHON 4. While Loops (25%) You will be writing a "shell" application, it will be on...
1. Write 4 simple shell scripts. Each question will ask you to write one or more command lines to solve a problem. Put the command(s) from each problem into a file named problem1.sh, problem2.sh Note that if you want your script to be interpreted by bash, each file should start with the line: #!/bin/bash and will have one (or more, as needed) commands following it. To execute each script in bash, so you can determine if it is working or...
Hello, please help with the following, you're tasked with writing a shell script named “rpsm.sh”. The script reports and prints (to stdout) selected storage management information. Think of it as “RePort Storage Management”. The easy way to describe what the script needs to do is to look at what it should display in the case where you provide incorrect parameters, or in the case where you provide “-h” for help: Usage: ./rpsm.sh <options>< directory> Reports selected information about specified directory...
Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple program. Generally, it reads a file as specified by the user and prints its contents. A typical usage is as follows, in which the user wants to see the contents of my-cat.c, and thus types: prompt> ./my-cat my-cat.c #include <stdio.h> ... As shown, my-cat reads the file my-cat.c and prints out its contents. The "./" before the my-cat above is a UNIX thing; it...
You will write a C program, q1 sequence.c, that computes the value of the nth term in any recursive sequence with the following structure: an = c1 · an−1 + c2 · an−2 a0 > 0 a1 > 0 c1 6= 0 c2 6= 0 Your C program will take 5 integer arguments on the command line: n, a0, a1, c1 and c2. n must be an integer greater than or equal to 0. If more or fewer arguments are...
. . In this programming assignment, you need to write a CH+ program that serves as a very basic word processor. The program should read lines from a file, perform some transformations, and generate formatted output on the screen. For this assignment, use the following definitions: A "word" is a sequence of non-whitespace characters. An "empty line" is a line with no characters in it at all. A "blank line" is a line containing only one or more whitespace characters....
Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will write a client and server program that enables the client to determine the round-trip time (RTT) to the server. To determine the RTT delay, the client records the time on sending a ping request to the server, and then records the time on receiving a ping response from the server. The difference in the two times is the RTT. The ping message contains 2...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...
1 Overview and Background Many of the assignments in this course will introduce you to topics in computational biology. You do not need to know anything about biology to do these assignments other than what is contained in the description itself. The objective of each assignment is for you to acquire certain particular skills or knowledge, and the choice of topic is independent of that objective. Sometimes the topics will be related to computational problems in biology, chemistry, or physics,...
could you please help me with this problem, also I
need a little text so I can understand how you solved the
problem?
import java.io.File; import java.util.Scanner; /** *
This program lists the files in a directory specified by * the
user. The user is asked to type in a directory name. * If the name
entered by the user is not a directory, a * message is printed and
the program ends. */ public class DirectoryList { public static...
can i get some help with this program
CMPS 12B Introduction to Data Structures Programming Assignment 2 In this project, you will write a Java program that uses recursion to find all solutions to the n-Queens problem, for 1 Sns 15. (Students who took CMPS 12A from me worked on an iterative, non-recursive approach to this same problem. You can see it at https://classes.soe.ucsc.edu/cmps012a/Spring l8/pa5.pdf.) Begin by reading the Wikipcdia article on the Eight Queens puzzle at: http://en.wikipedia.org/wiki/Eight queens_puzzle In...