Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ex. 3 Defining functions in shell(4 Points) In this exercise, you will update the script showusr that is given to you (you can use vi

Ex. 3 Defining functions in shell(4 Points)

In this exercise, you will update the script showusr that is given to you (you can use vi to edit this file), to write a function fname, that accepts a userid (such as your socs unix account) as the argument and sets an environment variable FNAME with the value that is the first name of the userid (explore the pinky command to get the first name of the userid). The function will also return an integer code to indicate its status (see examples below). Do not use the exit command in the function !

1.(1 Point) For properly commenting throughout the source code.

2.(1 Point) If fname is not passed an argument, set the variable FNAME to ERROR and return a value of 1. Below is an example of me loading the function to shell environment and then executing it (with no argument). I am using the echo command to check the return code as well as the value stored in FNAME.

3.(1 Point) if the argument passed to fname cannot be found among the sessions logged in, it should set FNAME to NOTFOUND and return 0.

4.(1 Point) if the userid passed as argument to fname is found among the sessions logged in, it should set FNAME to the first name of that user and return 0.

You should turn in your modified showusr script.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions

Question

Explain the basic concept involved in stepwise regression.

Answered: 1 week ago

Question

Do you believe that Matilda overreacted to James? Why or why not?

Answered: 1 week ago