Which will be executed had these names

Assignment Help Computer Engineering
Reference no: EM1336616

How would I write a shell script to locate executable files? This script takes a list of file names from the command line and determines which would be executed had these names been given as commands.

The search path should be based only on the user's PATH environment variable. I don't want to use use the Unix which command, the ksh whence (type) command, or the bash type command.

The script should find only the first occurrence of the "file". If the file is not found, the script should print an error message that the file was not found in the user's path. (Both the filename and the users path should be printed.)
If the first parameter is '-a', then the script should print all occurrences of the executable file in the user's path. Again if the file was not on the path, an error message should be displayed.

I also don't want to use temporary files.

The shell variable PATH defines the search path for the directory containing the command. Alternative directory names are separated by a colon (:). The current directory can be specified by two or more adjacent colons, or by a colon at the beginning or end of the path list.
If the command name contains a / then the search path is not used. Otherwise, each directory in the path is searched for an executable file.
usage: mywhich [-a] command ....

For example:

prompt> mywhich ls
/bin/ls

prompt> mywhich -a cc
/bin/cc
/usr/ucb/cc

prompt> mywhich ./mywhich
./mywhich

prompt> mywhich fooblar
fooblar not found

prompt> mywhich ksh sh csh bash
/usr/bin/ksh
/bin/sh
/bin/csh
/usr/local/bin/bash

Reference no: EM1336616

Questions Cloud

Pricing in absence of arbitrage opportunity : A McDonalds Big Mac value meal consists of a Big Mac sandwich, large Coke, and a large fry. Assuming that there is a competitive market for McDonalds food items
Comparing statistical analysis : I am working on a graduate level paper about using "Discriminate Analysis and other models" in Bankruptcy prediction and having trouble understanding the basic concepts of the overall nature of this assignment.
Illustrate what will happen to the equilibrium level : Illustrate what will happen to the equilibrium level of income if investors become optimistic about the country's future and raise their investment.
Assess various scenarios as a part of developing forecasts : How is it helpful to assess various scenarios as a part of developing forecasts?
Which will be executed had these names : How would I write down a shell script to locate executable files? This script takes a list of file names from the command line and determines which would be executed had these names been given as commands.
Explain how does the size this effect depend on the volume : Explain how is Brazil affected, explain how does the size of this effect depend on the volume of trade between Brazil and the United States.
Explain poulation growth and sum of annuities : Explain Poulation Growth and Sum of annuities and What would the population in 1990 have been if growth had continued in this same pattern
Comparative analysis of relationships : Discuss in detail the three contextual relationships between drug use and crime using examples from the newspapers, internet, or other professional or public journals.
Determine efficiency : A plant has an effective capacity of 900 units per day and produces 600 units per day with its product mix; determine its efficiency?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Configuring a database

Configuring a Database

  How to handle the customervalidator''s servervalidate event

Write down a method that handles the CustomerValidator's ServerValidate event. In addition, write a JavaScript function for the CustomValidator's CustomValidationFunction property.

  Assume that you know what k is

imagine you are given an array A of n sorted numbers that has been circularly shifted k positions to the right. For example, {35, 42, 5, 15, 27, 29} is a sorted array that has been circularly shifted k = 2 positions, while {27, 29, 35, 42, 5, 15} ..

  Compare the two non-sequential file structure models

What advantages does first one have over the second and what advantages does the second have over the first? What would be your criteria for choosing one over the other for different applications.

  The cost of maintenance over a lifetime of a system

What are some of the things management can do to ensure efficient and effective maintenance.

  Software engineering and microprocessor systems

Software is required for a simple house burglar alarm system.

  Program on different statements

Program on different statements

  Write down program that models an employee

Write down program that models an employee

  Create an announcement of the new system roll out

There are five centers with about 650 members and 30 employees in each location. The system will be used by both members and fitness consultants to track participation. The primary purpose is to assist the fitness center in obtaining the competiti..

  Make perl script in order to display a basic web page

design a Perl script in order to display a basic Web page and display system information that is dynamic using Perl on the screen such as date and time as well as the host and how long system has been up.

  Internet protocol-version 4 and version 6

Explain why do we require a new Internet protocol? Compare and contrast the version 4 and version 6.

  How to insert a row into the student table

Make yourself a student by writing and executing an INSERT statement to insert a row into the STUDENT table with data about you. Use one of the zip codes you inserted.

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