Explore positional arguments and parameter expansion

Assignment Help Programming Languages
Reference no: EM132571892

Part A

Objectives : Develop CLI/Shell and vi skills. 

Explore positional arguments and parameter expansion.

Exercise: 1. Login to your server vm using ssh login. Do not use a ttysession!

2. Launch tmux , maximize it and split into two vertical panes. Use LHS to write the script and RHS to execute it. 3. Write a shell script 300123456-a3.sh to perform the following : 3.1. 05pts. Use command substitution to pass the current working directory in $1 . 3.2. 05pts. Exit with return code 2 immediately if the number of arguments passed is zero. 3.3. 05pts. Create an empty file samplefile if it does not exist in current working directory. 3.4. 05pts. Store the absolute path to samplefile in a variable _SFILE using $1 and the filename. 3.5. 05pts. Use parameter expansion to extract the filename samplefile from _SFILE .Hint : Remove all characters as longest matching pattern from the start of the absolute path. 3.6. 05pts. Use parameter expansion to extract the path info in _SFILE by removing the filename from the end. 3.7. 05pts. Print 3.5 and 3.6 in a single echo statement and exit with 0. 3.8. 05pts. Print the contents of your script with line numbers. 4. All your coursework must comply with submission guidelines to be accepted.

Part b

Objectives : 1. Use for and while loops in CLI. 2. Task automation using at and cron commands.

Exercise : 1. Login to your server as regular user using ssh. 2. Launch tmux and split the terminal into two vertical panes. 3. 15pts. Using for loop in CLI : 3.1. In the left pane, process the contents of /etc directory to print filemode, filesize, and filename of text files using a for loop, command substitution, and pipes. a) Use ls -1 /etc when creating the list in the for statement. b) In the body of the loop, use test command to see if the entry is a file or a directory. Proceed only if it's a file, ignore if it's a directory. Note that you will need to prepend /etc to filename because ls -1 returns only the filename as in ls -l /etc/$_FNAME. c) Use tr command to squeeze multiple blanks into one blank in each line, like tr -s' ' . d) Use cut command to select individual fields in an input line. e) Use tr command again to translate field separator, aka delimiter, blank to a tab as in tr ' ' '\t' . f) 0pts. Use head command to limit the size of listing. 4. 15pts. Using while loop in CLI to read from a file : 4.1. In the right pane, read the contents of ls.etc file to print filemode, filesize and filename of text files using a while loop. a) Save the output from ls -l /etc command in a file ls.etc . b) Use a while loop to read ls.etc line by line into a variable _LINE. c) Use echo command to pipe the output to cut command to select the fields to print. d) Replace delimiter blank with tab character. e) Use grep to filter in only the lines that don't have a d in the first position as in grep -v ^d . f) 0pts. Use head command to limit the size of listing. 5. 10pts. Task scheduling using at : 5.1. Create a shell script 300*.at which a) tests if a file /tmp/norun does exist. If yes, it will echo removing /tmp/norun with a timestamp of the form YYYYMMDD-HH:MM:SS to 300*.log (hint: use %Y%m%d-%T format of the date command) and remove /tmp/norun . b) reschedules itself to run 5 minutes later using at command. 5.2. Create a cron entry to run a script 300*.crn every 1 minute every day of every month.

Reference no: EM132571892

Questions Cloud

Entrepreneurs and small business : Reflect on the contributions to society of small businesses and consider two benefits and drawbacks of small business ownership.
How do prepare entries that are necessary at April : A machine cost $244,800, has an annual depreciation expense of $48,960, How do prepare entries that are necessary at April 1, 2018
Contemplating launching a new magazine : A young journalist is contemplating launching a new magazine that will feature wildlife, plant life, and nature around the world.
What was flower shop margin of safety : What was Flower Shop Margin of Safety, measured in sales dollars? Total mirrors sold: 20,000.Total sales revenue: 855,000. Total fixed costs: 300,000
Explore positional arguments and parameter expansion : Explore positional arguments and parameter expansion - Task automation using at and cron commands - reschedules itself to run 5 minutes later using at command
Do you think this entrepreneur would need : Do you think this entrepreneur would need to raise closer to $1 million or $10 million in startup capital? Why?
Find what was the return on sales : During a recent year ACC had Sales Revenue of $800,000, Sales Turnover of 4 and a residual income of $40,000. What was its Return on Sales?
Calculate the weighted-average accumulated expenditures : For the purpose of determining the amount of interest cost to be capitalized, how do calculate the weighted-average accumulated expenditures
What is the importance of organizational consulting : What are the most significant differences between organizational consulting and team member coaching? What is the importance of organizational consulting?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd