Script-Lab1
.docx
keyboard_arrow_up
School
Seneca College *
*We aren’t endorsed by this school
Course
102
Subject
Computer Science
Date
Jun 2, 2024
Type
docx
Pages
11
Uploaded by CommodoreTank14566
OPS102: Introduction to Shell Scripting Lab
Include screenshots of your outputs and upload Task 1
Create a Bash Shell script to clear the screen and then display all users that are currently logged onto the system.
We created a text file named week7lab in nano editor, we initialized the file with a “shebang” :- “#” and “!” to make it a bash shell script . Then we added the clear and who command to clear the output screen and display all the users currently logged onto the system. We gave the user execute permission for the file week7lab as it is necessary.
Task 2:
Write a Bash shell script to display the following message using an environment variable so it will work in any user’s terminal if the shell script was issued:
My username is: (your-username)
We edited the text file week7lab by adding an echo command and an environmental variable $USER which displays the username of the user. This would work on anyone’s terminal as it has no hard code and takes different input for different users.
Task 3:
Write a Bash shell script to prompt the user for their full name and prompt the user for their age
to be stored in user-defined
variables. Display the following output using the values of those variables:
Enter your Full Name: (your full name)
Enter your Age: (your age)
Hello, my name is (your full name), and I am (your age) years old.
We used the read command to take input from the user through the prompt and store that in the user defined variables name and age, then we used the echo command to display the information by calling the variables by using the $ sign.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Bash shell
arrow_forward
Using the following data file (delimited by a space or tab) November 400January 200June 400March 200April 200May 300July 400August 300September 400February 300October 300December 200Write a bash script that will use a loop structure to process the data file line by line. Do not use the command awk. The script will send the output to a file in the following format:Month Sales-------- -------January 200February 300March 200April 200May 300June 400July 400August 300September 400October 300November 400December 200======Total show the totalAverage show the average
arrow_forward
1) Write a bash script to demonstrate while loop which displays "While Loop Demo" and exits when key q is typed.
2) Write a bash script using while loop which displays date, your username and current directory every 15 seconds
scripts MUST be in bash shell linux commands
arrow_forward
UNIX ASSIGNMENT - IXQuestion 8 : Rename all the files within a folder with suffix “CS_” i.e. suppose a folder has two files file_a.txt and file_b.pdf than they both should be renamed from a single command to CS_a.txt and CS_b.pdf
arrow_forward
Do it soon
arrow_forward
Name of Experiment: Permissions in Ubuntu
Change the permissions
Permissions can be changed with `chmod` command. Suppose you want to change the permission for a particular file or a folder, the first approach is through `chmod` command.
Changing Ownership and Group
Change the ownership of a file/directory
Example: chown user filename
Provide screenshot of you work
arrow_forward
CSE460 MID ASSIGNMENT
Given the Linux shell command descriptions, please write down the corresponding shell commands in a
terminal window.
• Copy paste the shell commands(using Control+shift+C) to do the following
• give screenshots so that I can understand
b) Write a shell script, which first ask the user for a number.
then,
-> Print "Panther" if the number is divided by 10 but is neither a multiple of 4 and neither a multiple of 5.
-> Print "Oodama_Rasengan" if the number is a multiple of 5 or 6, but not both.
-> Print "Rasen_Shuriken" if the number is a multiple of both 5 and 6
arrow_forward
A client sends you two files containing two shapes to be used in the design of a logo. Your computer could not recognize the format of the files sent in order to display them, so you manually open the files on a text editor, and found the following content within each file:
File A
File B
(-2.5, -2)
(0.5, 4)
(2.5, 3)
(-0.5, -3)
START (-3, -2)
<√34, 30.964°>
<√10, 71.565°>
<-5, -3>
<-1, -3>
Based on this data, name the types of the two shapes, justifying your answer by assessing the properties of each shape, and drawing a small sketch for each.
arrow_forward
You will develop a client side and a Servlet program that will work with a database.
1. The client (front end) should have a title "NJIT Credit Union", centered.
2. The client should have a background color.
3. The client should have a text field with label 'UserID' where user will enter userID
(integer) and a Submit button with text "Submit".
4. An unsuccessful authentication should have a message printed on the screen, in red,
stating that "Your authentication has failed, please try again.” (no pop up message).
At this point the text field should get cleared and ready to accept a new input. Your
program should not exit.
5. A successful authentication should be followed by a message on the screen, in green,
stating that "Your authentication is successful" (no pop up message).
6. There should be two other text boxes with label "Deposit" and "Withdraw" where
user will enter an amount (you should accommodate for decimals). These two text
boxes should only be enabled after successful…
arrow_forward
CENTENNIAL COL GE: LAB TEST SUBMISSION
Debug the following bash script:
# Prompt the user and get input for username and password and store username #in a
variable and password in another variable.
#Write this information in two files as userlogin. txt and passlogin.txt.
# start
echo "Enter username"
read username
echo "Enter password"
read password
if [I (Susername = "guest" & $password = "etec" ) ]]: then
echo Şusername > userlogin.txt passlogin.txt
else
echo "invalid user"
fi
arrow_forward
Create a simple BASH shell script that executes the commands specified by you, using a number of different escape characters. Submit the script to your instructor in order to ensure that it functions correctly.
Create a more complete BASH shell script that requires user input to be read and uses either an if, case, for, or while construct. Be sure to specify exactly what the script should do, and then submit the script once you complete it.
arrow_forward
Select all of the following Bash filename patterns that would only match the following filenames (i.e., no other files except these four could ever be matched by the chosen pattern(s)):
syscore5a.bin
syscore5b.bin
syscore9b.bin
syscore9a.bin
O syscore (5,9) {a,b).bin
O syscore{519} {a|b}.bin
O syscore [59] (a, b}.bin
O syscore [519] [alb].bin
O syscore [59ab].bin
O syscore [59] [ab].bin
O syscore [5, 9] [a,b].bin
O syscore (5,9}[ab].bin
arrow_forward
Questions:
Answer the below questions inside the script itself.
How is a comment written in a script?
2.What is a self-documenting variable or argument? Give an example.
Application:
Write a skeleton script titled: skeleton.sh. Include the following in the script:
The shebang to BASH
Comments that include:
The name of the script file
Name of the original author
Date written
Date last modified
Purpose
Brief description of the implementation of the script
Save the script in your bin directory.Lastly:
Upload a copy of the script file.
arrow_forward
We will use the file classlist.txt. Note that it contains a list of usernames.
3.
Write a script called finduser that is to be called as follows, where classlist is the name of the classlist
file, and username is a particular student's username, either first name or last time.
./finduser classlist username
The script should
check that the correct number of arguments was received and print an error message if not,
check whether the classlist file exists and print an error message if not,
print the line of the given username in the classlist file
If you have not been doing so all along, you should now add some comments to your script and thoroughly
test it!
4.
Write the script into your lab report.
arrow_forward
Implementing User Input and
Comments in a Script
1. Go to your main.py file.
2. On the first line, add a docstring explaining what your
file does. Then, assign a variable called whole_num to
the user's input and cast it to an integer.
3. Next, print 10 underscores as the top border of the
table.
4. On the first line print your whole number, then
multiply your whole number by multiples of 2's till 10
and print that out.
5. Finally, print 10 underscores again for the bottom
border of the table, as in step 3.
6. Run the file by using the python3 main.py command.
The output should be like Figure 1.10.
>_ Terminal
workspace $ python3 main.py
Generate a multiplication table for: 7
Number: 7
2: 14
4: 28
6: 42
8: 56
10: 70
workspace $
x +
Figure 1.10
arrow_forward
Enter a BASH glob pattern that will match all files with 7-character names that end with ‘.txt’, start with the letter ‘c’ and the third letter of ’t’.
All there is
arrow_forward
WEB DEVELOPMENT IS THE SUBJECT
QUESTION -
Create a Application that allows the user to customize the web page. Your design
must include CSS. The application should consists of three files as follows
a. Ask the user to login and read form the database to determine the
authentication. If the user is not known, the second file is loaded asking
the user to fill up the form to store personal data
b. Write a Java script to check the user is known user
c. Use cookies for storing the user details and display the user name when
the user moves on the next page.
arrow_forward
5
arrow_forward
Linux commands:
In this part of the lab, you will run Linux commands, capture their output in a format that shows the command and its results in an easy way (command-> new line-> output - > new line-> new line-> command, .... etc).
In your output file, make sure to print out the name of your user account and todays date. It should look something like this "My Student Account is " , "Todays Date is ".
Can someone please help with this ?
arrow_forward
Please answer the following Bash question, please show your output as well.
1. Write a Bash function named ‘Generate-ID' that generates all possible UGA student id start with 900. The output should be saved into a file named studentID.csv.
2. Write a Bash function named ‘Find_word’ that read wordlist.txt file to find all words end with “ing” and output these words to WordEndIng.csv.
3. The auth.log file (path: /var/log/auth.log) and syslog file (path: /var/log/syslog) are two of the most important log files in Linux. Generally, adversaries target these files so that system administrators couldn’t track what attackers are doing. Write a function named get-linuxlog() that reads all the above two files and stores them into a file named linuxeventlog.txt (Hint use the ‘cat’ command)
arrow_forward
Good day I need help understanding how to do the following in bold using nano:
Write a Bash shell script named move.sh.
1) Insert a heading line as follows to the top of the file and output the resulting data to a file called move1.txt.
Name Phone Number Jan Feb Mar
arrow_forward
Write a Java GUI application that will keep track of a user’s contact list. The application must contain the contact mobile number, work number and email address. Q.3.1 On the form, create a list box that will allow the user to select a contact name, which is populated from a text file. Also create a search button that when clicked will display the mobile number, work number and email address. Q.3.2 Create a sequential file (contacts.txt) that contains data for the following fields: The contact name; The contact mobile number; The contact work number; The contact email address. Q.3.3 Load the data from the contacts.txt file and populate the list box with the contact names. Include a feature to inform the user on the amount of contacts.
Contacts:
Joe Bloggs082 123 1234011 123 1234jb@gmail.comJeff Jones072 157 1545021 555 5555jj@gmail.com
arrow_forward
Write a bash script
goals:• Use Linux shell commands within your script• Provide user feedback• Use loops• Use conditionals
Script 3:
arrow_forward
20. Create a linux bash script to get a filename as input and then it should check and display if file exist and size
is greater than zero, then should get input of any file comparison operator and then display if the file is true
or false for that given file comparison operator.
21. Create a linux bash script to get three numbers as positional parameters then display the greatest and least
of the given numbers. If positional parameters are not given then message "This script requires 3 numbers
as positional parameters, Try again.." should be displayed.
arrow_forward
This is for Advanced Java Programming
Write a test program that reads words from a text file and displays all non-duplicate words in ascending order and then in descending order.
- The file is to be referenced in the program, not needing to be used as a command line reference.
- The word file is to be titled collection_of_words.txt and included in your submission.
Write test code that ensures the code functions correctly.
arrow_forward
T/F
6. Unlike the Exception type, which is included in java.lang, the IOException class is included in java.io.
arrow_forward
You are in the same group as Sam, Tom, Bill, and so on. The permissions field on a file you own named answer is ----r-----. Who can read the file?
arrow_forward
Project One (1): Image
2 Imagguil@compute-/private/courses/es2211/W21/assignments/asn3/p.
fimagguilecompute projijs ./proji
Enter values for Layers, Rows, Columns (elements in each row): 234
Original Matrix
Layer 1
(1) 71
72
57
48
49
(2 ) 99
layers
57
( 3 ) 12
58
57
18
23
prompt
Layer 2
(1) se
( 2) 30
(3) 94
77
83
12
99
90
42
84
80
96
row
number
Enter values for Layers, Rows, Columns (elements in each row): e e e
FINISHED
(Imagguilecompute projijs
(Imagguilecompute projijs
Code for generating random integers:
int x, m = 100;
time_t t;
srand ( (unsigned) time (st));
x = (rand () % m) +1;
where:
time_t is defined in the C library of time.h
m is range. In this case 100 signifies the range of 0 to 99, so we add I to the result.
(note: m will vary in the second project to match to the matrix size.)
arrow_forward
this is a java program code please do the code what in the question says and please follow what in the question says and dont copy or plagarise from other sources
arrow_forward
Write a complete bash script that takes a filename as input using the readcommand. The script first checks if the file exists. If the file exists thencontinue with rest of the script. If the file does not exist output that itdoesn’t exist and end the script. If the file exists then check if the file isexecutable. If the file is executable, output a message indicating it isexecutable else if the file is not executable then make the file executableusing the chmod command and output a message indicating that the file isnow executable. Also run a ls -l on the file to verify to the user that the filehas been made executable. Use If statements and test file operators. (Usage: executableFile.sh)
arrow_forward
When importing a Text file, why is it important to move through each step of the Text Import Wizard?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Related Questions
- Bash shellarrow_forwardUsing the following data file (delimited by a space or tab) November 400January 200June 400March 200April 200May 300July 400August 300September 400February 300October 300December 200Write a bash script that will use a loop structure to process the data file line by line. Do not use the command awk. The script will send the output to a file in the following format:Month Sales-------- -------January 200February 300March 200April 200May 300June 400July 400August 300September 400October 300November 400December 200======Total show the totalAverage show the averagearrow_forward1) Write a bash script to demonstrate while loop which displays "While Loop Demo" and exits when key q is typed. 2) Write a bash script using while loop which displays date, your username and current directory every 15 seconds scripts MUST be in bash shell linux commandsarrow_forward
- UNIX ASSIGNMENT - IXQuestion 8 : Rename all the files within a folder with suffix “CS_” i.e. suppose a folder has two files file_a.txt and file_b.pdf than they both should be renamed from a single command to CS_a.txt and CS_b.pdfarrow_forwardDo it soonarrow_forwardName of Experiment: Permissions in Ubuntu Change the permissions Permissions can be changed with `chmod` command. Suppose you want to change the permission for a particular file or a folder, the first approach is through `chmod` command. Changing Ownership and Group Change the ownership of a file/directory Example: chown user filename Provide screenshot of you workarrow_forward
- CSE460 MID ASSIGNMENT Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal window. • Copy paste the shell commands(using Control+shift+C) to do the following • give screenshots so that I can understand b) Write a shell script, which first ask the user for a number. then, -> Print "Panther" if the number is divided by 10 but is neither a multiple of 4 and neither a multiple of 5. -> Print "Oodama_Rasengan" if the number is a multiple of 5 or 6, but not both. -> Print "Rasen_Shuriken" if the number is a multiple of both 5 and 6arrow_forwardA client sends you two files containing two shapes to be used in the design of a logo. Your computer could not recognize the format of the files sent in order to display them, so you manually open the files on a text editor, and found the following content within each file: File A File B (-2.5, -2) (0.5, 4) (2.5, 3) (-0.5, -3) START (-3, -2) <√34, 30.964°> <√10, 71.565°> <-5, -3> <-1, -3> Based on this data, name the types of the two shapes, justifying your answer by assessing the properties of each shape, and drawing a small sketch for each.arrow_forwardYou will develop a client side and a Servlet program that will work with a database. 1. The client (front end) should have a title "NJIT Credit Union", centered. 2. The client should have a background color. 3. The client should have a text field with label 'UserID' where user will enter userID (integer) and a Submit button with text "Submit". 4. An unsuccessful authentication should have a message printed on the screen, in red, stating that "Your authentication has failed, please try again.” (no pop up message). At this point the text field should get cleared and ready to accept a new input. Your program should not exit. 5. A successful authentication should be followed by a message on the screen, in green, stating that "Your authentication is successful" (no pop up message). 6. There should be two other text boxes with label "Deposit" and "Withdraw" where user will enter an amount (you should accommodate for decimals). These two text boxes should only be enabled after successful…arrow_forward
- CENTENNIAL COL GE: LAB TEST SUBMISSION Debug the following bash script: # Prompt the user and get input for username and password and store username #in a variable and password in another variable. #Write this information in two files as userlogin. txt and passlogin.txt. # start echo "Enter username" read username echo "Enter password" read password if [I (Susername = "guest" & $password = "etec" ) ]]: then echo Şusername > userlogin.txt passlogin.txt else echo "invalid user" fiarrow_forwardCreate a simple BASH shell script that executes the commands specified by you, using a number of different escape characters. Submit the script to your instructor in order to ensure that it functions correctly. Create a more complete BASH shell script that requires user input to be read and uses either an if, case, for, or while construct. Be sure to specify exactly what the script should do, and then submit the script once you complete it.arrow_forwardSelect all of the following Bash filename patterns that would only match the following filenames (i.e., no other files except these four could ever be matched by the chosen pattern(s)): syscore5a.bin syscore5b.bin syscore9b.bin syscore9a.bin O syscore (5,9) {a,b).bin O syscore{519} {a|b}.bin O syscore [59] (a, b}.bin O syscore [519] [alb].bin O syscore [59ab].bin O syscore [59] [ab].bin O syscore [5, 9] [a,b].bin O syscore (5,9}[ab].binarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT