IMG_7072
.png
keyboard_arrow_up
School
Macomb Community College *
*We aren’t endorsed by this school
Course
1710
Subject
Computer Science
Date
Jul 2, 2024
Type
png
Pages
1
Uploaded by AgentTeamGiraffe39
162 Chapter 8: Specifying Instructions to the Shell 0 10 MINUTES Lab Exercise 8.06: Gathering Error Numbers With redirection error, LaTrina can now implement all of the error checks, and check her own log file for messages. This will allow her to customize the program to trap every error the user generates. In time, her regist.exe will be crash-proof. She asks you how she can get the error codes for common UNIX errors. She knows what errors she is getting, but without the error codes she cannot program for the errors. You tell her about the $? variable, which holds the error code for the previous error. Learning Objectives In this lab, you will record error numbers for common commands. By the end of this lab, you'll be able to: e Determine the error code for any UNIX error Lab Materials and Setup The materials you need for this lab are: e Computer with Red Hat Linux 7.3 installed ® Pencil and paper Getting Down to Business The following table has several commands. Run the command and get the error number using the $? variable. Record the error number in the space provided. Recall that you will need to echo this variable to get the contents. You will have to apply the knowledge that you acquired in the Introduction to UNIX and Linux textbook by John Muster (McGraw-Hill/Osborne, 2002) for echoing variable contents. ¥ Warning Do not log in as root to run this exercise!
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Write a Java program that allows the user to specify a file name on the command line and prints the number of characters, words, lines, average number of words per line, and average number of characters per word in that file. If the user does not specify any file name, then prompt the user for the name.
arrow_forward
could you please code this on notepade.
arrow_forward
Write a Java program that reads from a URL and searches for a given word in the URL and creates a statistic file as an output. The statistic file needs to include some information from the URL.
URL address
Number of words in the URL page
Number of repetitions for a given word
displays the number of times the word appears. You need to have two functions, one for reading from the URL and the other function for searching the word.
arrow_forward
Simple Encryption. Write a java program that reads from a file specified by the user and encrypt the content of the file using a simple shifting technique. Also, ask the user to input the shift size. Output the encrypted message to another file whose filename is also provided by the user.
For example,
Shift size: 1
Message read from the file: Hello Encrypted message: Ifmmp
arrow_forward
Answer the given question with a proper explanation and step-by-step solution.
Hello, I am trying to make a program that prints the contents of a file but whenever I try to run it, it just prints a bunch of question marks infinitely and this only happens when I run it on a UTM virtual machine(Linux terminal). It works fine when I run it on my Mac terminal so I am not sure if it has to do with the virtual machine or my program. Please help!!
Image 1: cat.c
Image 2: input.txt
Image 3: output/results
arrow_forward
Write a program in HACK assembly, without using symbols, that implements the
described Feistel encryption system. The initial key, Ko, will be stored in RAM[1],
and the 16-bit plaintext will be stored in RAM[2]. The result of the encryption
should be stored in RAM[0]. Your solution should be submitted in a file called
"FeistelEncryption.asm".
arrow_forward
Implement a simple version of the linux cat command in C++. Use the system calls open(), get() and close().
cat - reads a file as specified by the user and prints its contents. A typical usage is as follows:
If from my terminal y run ./cat main.cpp
the contents of main.cpp. will be printed.
Your program cat can be invoked with one or more files on the command line; it should just print out each file in turn. Example:
[terminal]$ ./cat main.cpp main2.cpp #include <iostream>using namespace std;int main(){cout << "Hello, World!"; return 0;}#include <iostream>using namespace std;int main(){cout << "Programming is great fun!";return 0;}
As you can see content of main.cpp was printed first and the content of main2.cpp
arrow_forward
Create a python module called
MyEncryption to implement the
Cesar cipher encryption. The module
should contain two functions as
follow; encrypt ( plainfilename, key)
and decrypt ( cipherfilename, key).
The encrypt function reads plaintext
from a given filename, performs text
encryption using the given key, and
then writes the encrypted ciphertext
in an output text file. The decrypt
function reads ciphertext from a given
filename, performs text decryption
using the given key, and then writes
the plaintext in an output text file.
Create a text file with some text.
Import the MyEncryption module in
your main module and test both the
encryption and decryption functions.
arrow_forward
In Java
arrow_forward
Write a test client which takes a file path as an argument and reads each line one by one. The file can contain any number of DNA sequences (i.e., Strings.). After reading each DNA sequence, your code should print the DNA sequence first. Please follow the screenshot below for the output format.
If the DNA sequence is valid DNA, report that and print out its complement as well as whether or not it is a Watson-Crick complemented palindrome. If the DNA sequence is not a valid DNA, only report that.
Continue this process for each DNA sequence in the text file. Separate the outputs for each sequence by printing a line as shown in the screenshot.
In your project directory, create a new directory named ‘in’. The in folder will contain the input text file, titled sequences.txt. To run the code, your program argument should be in/sequences.txt
Method Summary.
Return Type
Method
1
boolean
isValid(String DNA)
2
String…
arrow_forward
Implement a simple version of the linux grep command in C++. grep - Looks through a file, line by line, trying to find a user-specified search term in the line. If a line has the word within it, the line is printed out, otherwise it is not. Use the system calls open(), getline(), close().
Requirements (examples run from. terminal)
Your program grep is always passed a search term and zero or more files to grep through (thus, more than one is possible). It should go through each line and see if the search term is in it; if so, the line should be printed, and if not, the line should be skipped.
[terminal]$ ./grep ! main.cpp main2.cppcout << "Hello, World!";cout << "Programming is great fun!";
The matching is case sensitive. Thus, if searching for world, lines with World will not match.
Lines can be arbitrarily long (that is, you may see many many characters before you encounter a newline character, \n). grep should work as expected even with very long lines. For this,…
arrow_forward
In UNIX, how would you remove the directory test and all files and subdirectories
(recursively) in it? The directory test is located in (is a subdirectory of)
/home/myid/smith/projects.
O rmdir /home/myid/smith/projects/test
O rmdir -r /home/myid/smith/projects/test
rm -r /home/myid/smith/projects/test
O rm -r projects/test
arrow_forward
Implement a system of three concurrent processes which read and write sequence numbers to a file. Each of the three processes must obtain 200 integers from the file. The file only holds one integer at a given time. Given a file, F, containing a single integer, each process must perform the following steps:
Please show steps and answer.
arrow_forward
You are a cyber investigator, your task is to write a python program that can read file signatures from a file and save them into a list. Each file signature is an element of your list. Then, try to find out if there is a JPG file in there. If there is a JPG file, print out a True on screen. (File Signature for JPG file is: FF D8 FF DB)
The input file is: FSCS360_Midterm_Exam_Part2.txt
arrow_forward
In Python please. Need help deleting byte information from a text file. It involves TCP programming. The user enters information of a student (ID, first, and last name). The user has the option to delete a student's information by looking up the ID and removing it from the text file.
arrow_forward
Unix-based operating systems usually include a tool named tail. It displays the last 10 lines of a file whose name is provided as a command line argument. Write a Java program that provides the same behavior i.e. the user can specify how many lines to print from the terminal. Display an appropriate error message if the file requested by the user does not exist, or if the command line argument is omitted.
Note: Make sure to display the last n lines of a file whose name is provided as a command line argument. You might need to pass a file as an argument, therefore make sure to have access to a sample file, the contents of which you want to print out.
arrow_forward
IN PYTHON: Decrypting with ascii
I have a file called 'dict.txt'. This file contains over 50,000 english words. One word from this file is used as a key (we do not know which one of course). Some have capital letters.
I have another file called 'decrypt.txt' which is a file containing a string of numbers i must decrypt using a key found in the 'dict.txt'. This 'decrypt.txt' file message has length of 300.
My question is, since i do not know which word (from the file with the 50,000+ words) is the key I must use to decrypt the other file, how do I write a function that:
loops through all possible keys from 'dict.txt' to find the one that decrypts my file 'decrypt.txt' best? Somehow i must count how many 'words' are actual words to determine which key is best and then print my final decrypted message.
arrow_forward
Kindly help me with this python program
write a system to support sending and receiving of quotes. The client program will connect to a quote server which in turn will send out a quote to that specific client. The quote server will read a file containing one-liner quotes stored on a text file that will be the basis for quotes sent to clients
arrow_forward
Write a program that will read the file text.txt which is provided and the encryptedmessage in there. Please write back the decrypted message into the output.txt file.When you see the message in the output.txt file, you need to submit the java codefile. You need to use Rot13 class for decrypting the message. Do not need to submit in the output.txt file.
file example:
public class FileExample {
public static void main(String[]args){
try {//create file object for input.txtFile in_file = new File("src/input.txt");//create file object for output.txtFile out_file = new File("src/output.txt");
//read the input.txt file with ScannerScanner read = new Scanner(in_file);//write the output.txt file with PrintWriterPrintWriter w = new PrintWriter(out_file);
while(read.hasNextLine()){w.write(read.nextLine());}
//don't forget to closew.close();
// while(scan.hasNext()){// System.out.println(scan.next());// }
}catch(Exception ex){ex.getStackTrace();}
arrow_forward
Write a script that opens a file containing a list of passwords and checks to see if the passwords are strong. 1. Save a list of five passwords in a text file. 2. Write a Python script that opens the text file and reads the passwords. 3. For each password, use regular expressions to check the password strength (I recommend creating a module to do this). For a password to be considered strong, it must satisfy the following requirements: + minimum length 8 characters + must contain one or more alphabetical characters [a-z] + must contain one or more Uppercase characters [A-Z] + must contain one or more numeric characters [0-9] + must contain one or more special characters [_$!]
arrow_forward
I have managed to get my random number generator working.
The range of the random number and how many random numbers are read in from a file and I can read them with no problem
The generated random numbers are written to a file with the sum of those numbers.
My issue is that everytime only the first line is correct, the following lines have the correct random numbers but the sum is totally wrong
arrow_forward
This question was rejected because lack of a text file, which I do not see a way to upload. I saved the first part of the file as an image because that is all I can upload. If that doesn't suffice, please advise how to include a text file.
In C++, I would like some help improving or making a better password lookup function for a Hash Table class/program I made,
The function: it is supposed to lookup a user password using their ID and name which I read in from a text file. The one I have only works for the first 10 records, which I highlighted below in the program.
string lookupPassword (string inUserID, string inUserName){
string thePassword;
...
return thePassword;
}
Here is part of the program thus far:
// Hash.cpp
#include <iostream>#include<string>#include<iomanip>#include<fstream>using namespace std;//node classclass nodeBST {private: //user data string userID; string userName; string userPW; //BST left and right children nodeBST*…
arrow_forward
Write the C or C++ program system2 that reads, when being executed, OS commands via the "command line parameter" C/C++ feature, and then executes them. The
command line parameters must be legal Unix/Linux commands. Print the number of commands entered. To prepare, read about argc, argv, and envp. Focus is only argc and
argv. A sample execution by fictitious user "mike" is:
herb$ ./a.out pwd ls whoami
argc
4
pwd
argv[1]
Executing command
/Users/mikey
'pwd'
= ls
argv[2]
Executing command 'ls'
Applications
Contacts
Music
Pictures
familie
herb
Downloads
testl
Favorites
Library
Movies
testl.c
pix_low_2020 test2
test2.c
Desktop
Public
Documents
a.out
test.c
argv[3] = whoami
Executing command
mikey
'whoami'
arrow_forward
Suppose you have Java source files under the directorieschapter1, chapter2, . . . , chapter34. Write a program to remove the statement package chapteri; in the first line for each Java source file underthe directory chapteri. Suppose chapter1, chapter2,. . . , chapter34are under the root directory srcRootDirectory.The root directoryandchapteridirectory may contain other folders and files. Use the followingcommand to run the program:java Exercise12_20 srcRootDirectory
arrow_forward
Implementing an arithmetic server using socketsWrite a program with two parts: 1) a client, and 2) an arithmetic server. The job of the client is toaccept input from the keyboard and translate strings that you type into requests to the arithmeticserver. In other words, the client should translate strings such as "3 + 4" into a request to thearithmetic server.
There are two versions of this program you have to implement:1. The client and server communicate using UDP.2. The client and server communicate using TCP.You have to submit the following:
(a) the client program
(b) the server program
(c) output showing your program works correctly (you can run both the client and the server on the same computer for generating this output)
arrow_forward
Write a Java program that opens a file and counts the whitespace-separated words in that file. You may obtain the name of the input file either from the command line or via prompt and user input. Be sure to clearly document the method chosen.
You may test your program using any number of text files; however, you must be sure to test your program using the Sample Text File provided at the end (excerpt.txt).
Sample Text File
There was nothing so VERY remarkable in that; nor did Alice think it so VERY much out of the way to hear the Rabbit say to itself, `Oh dear! Oh dear! I shall be late!' (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at the time it all seemed quite natural); but when the Rabbit actually TOOK A WATCH OUT OF ITS WAISTCOAT- POCKET, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to…
arrow_forward
Write a program that replaces all occurrences of a word with anew word in all the files under a directory, recursively. Pass the parameters fromthe command line as follows:java Exercise18_31 dirName oldWord newWord
arrow_forward
The task is to implement part of a linter program using python. Specifically, you must be able to
scan for grouping symbols ( "()", "[]", "{}") and ensure that there are no hanging open symbols or
stray closing symbols in the source file.
There will be files you will need to scan so you need the open() in your code. Also, you can use the
read() or readlines() to know which lines has no opening or stray closing symbols.
Example: You scan this code from a file, and you notice that there is a stray closing symbol ")".
1 int main(void) {
.
123
2
3
4
printf("Hello world"));
return 0;
}
The implementation must involve recursion in terms of scanning for the scope. If a different closing
symbol is encountered or the end of file is reached, the error message "Line :
missing closing symbol for "" should be displayed. For stray closing tags, the
message "Line : stray closing symbol for "".
Do not use "stack" in your code.
arrow_forward
Java program with a simple encryption. Read from a file specified by the user and encrypt the content of the file using a simple shifting technique. Also, ask the user to input the shift size. Output the encrypted message to another file whose filename is also provided by the user.
Example Output:
Shift size: 1Message read from the file: HelloEncrypted message: Ifmmp
Note: Provide a screenshot of the output with the same result with the example
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Write a Java program that allows the user to specify a file name on the command line and prints the number of characters, words, lines, average number of words per line, and average number of characters per word in that file. If the user does not specify any file name, then prompt the user for the name.arrow_forwardcould you please code this on notepade.arrow_forwardWrite a Java program that reads from a URL and searches for a given word in the URL and creates a statistic file as an output. The statistic file needs to include some information from the URL. URL address Number of words in the URL page Number of repetitions for a given word displays the number of times the word appears. You need to have two functions, one for reading from the URL and the other function for searching the word.arrow_forward
- Simple Encryption. Write a java program that reads from a file specified by the user and encrypt the content of the file using a simple shifting technique. Also, ask the user to input the shift size. Output the encrypted message to another file whose filename is also provided by the user. For example, Shift size: 1 Message read from the file: Hello Encrypted message: Ifmmparrow_forwardAnswer the given question with a proper explanation and step-by-step solution. Hello, I am trying to make a program that prints the contents of a file but whenever I try to run it, it just prints a bunch of question marks infinitely and this only happens when I run it on a UTM virtual machine(Linux terminal). It works fine when I run it on my Mac terminal so I am not sure if it has to do with the virtual machine or my program. Please help!! Image 1: cat.c Image 2: input.txt Image 3: output/resultsarrow_forwardWrite a program in HACK assembly, without using symbols, that implements the described Feistel encryption system. The initial key, Ko, will be stored in RAM[1], and the 16-bit plaintext will be stored in RAM[2]. The result of the encryption should be stored in RAM[0]. Your solution should be submitted in a file called "FeistelEncryption.asm".arrow_forward
- Implement a simple version of the linux cat command in C++. Use the system calls open(), get() and close(). cat - reads a file as specified by the user and prints its contents. A typical usage is as follows: If from my terminal y run ./cat main.cpp the contents of main.cpp. will be printed. Your program cat can be invoked with one or more files on the command line; it should just print out each file in turn. Example: [terminal]$ ./cat main.cpp main2.cpp #include <iostream>using namespace std;int main(){cout << "Hello, World!"; return 0;}#include <iostream>using namespace std;int main(){cout << "Programming is great fun!";return 0;} As you can see content of main.cpp was printed first and the content of main2.cpparrow_forwardCreate a python module called MyEncryption to implement the Cesar cipher encryption. The module should contain two functions as follow; encrypt ( plainfilename, key) and decrypt ( cipherfilename, key). The encrypt function reads plaintext from a given filename, performs text encryption using the given key, and then writes the encrypted ciphertext in an output text file. The decrypt function reads ciphertext from a given filename, performs text decryption using the given key, and then writes the plaintext in an output text file. Create a text file with some text. Import the MyEncryption module in your main module and test both the encryption and decryption functions.arrow_forwardIn Javaarrow_forward
- Write a test client which takes a file path as an argument and reads each line one by one. The file can contain any number of DNA sequences (i.e., Strings.). After reading each DNA sequence, your code should print the DNA sequence first. Please follow the screenshot below for the output format. If the DNA sequence is valid DNA, report that and print out its complement as well as whether or not it is a Watson-Crick complemented palindrome. If the DNA sequence is not a valid DNA, only report that. Continue this process for each DNA sequence in the text file. Separate the outputs for each sequence by printing a line as shown in the screenshot. In your project directory, create a new directory named ‘in’. The in folder will contain the input text file, titled sequences.txt. To run the code, your program argument should be in/sequences.txt Method Summary. Return Type Method 1 boolean isValid(String DNA) 2 String…arrow_forwardImplement a simple version of the linux grep command in C++. grep - Looks through a file, line by line, trying to find a user-specified search term in the line. If a line has the word within it, the line is printed out, otherwise it is not. Use the system calls open(), getline(), close(). Requirements (examples run from. terminal) Your program grep is always passed a search term and zero or more files to grep through (thus, more than one is possible). It should go through each line and see if the search term is in it; if so, the line should be printed, and if not, the line should be skipped. [terminal]$ ./grep ! main.cpp main2.cppcout << "Hello, World!";cout << "Programming is great fun!"; The matching is case sensitive. Thus, if searching for world, lines with World will not match. Lines can be arbitrarily long (that is, you may see many many characters before you encounter a newline character, \n). grep should work as expected even with very long lines. For this,…arrow_forwardIn UNIX, how would you remove the directory test and all files and subdirectories (recursively) in it? The directory test is located in (is a subdirectory of) /home/myid/smith/projects. O rmdir /home/myid/smith/projects/test O rmdir -r /home/myid/smith/projects/test rm -r /home/myid/smith/projects/test O rm -r projects/testarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education