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

  Describe the development of network architectures

explain the development of network architectures and its subsequent consolidation over past 20 years. Include topologies and the TCP/IP, Internetwork Packet Exchange/Sequence Packet Exchange (IPX/SPX), Network Basic Input Output System (NetBIOS), ..

  Multicast type connection

In DVMRP, routing messages are transmitted through a multicast type connection (a specific multicast address).

  What are some of the changes to technology

How has this technology impacted the development of new software? Even if the technology change is hardware related, software development can be impacted.

  How to use a nested select case statement

plan and build an application that works as a paper, scissors, and rock game. Draw a flowchart and write pseudocode before coding the application. Use two ComboBox controls to input the selections of the two players and label the ComboBox controls..

  You are a network support technician for a college

explain why each step is necessary. Suppose that your troubleshooting methodology leads you to determine that the problems was caused by a malfunctioning gateway. Suggest ways in which the problem could have been prevented.

  Relational-algebra queries

Utilizing the university example, write down the relational-algebra queries to determine the course sections taught by more than one instructor in the following given ways.

  Craete an inheritance hierarchy for classes quadrilateral

Write down an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy.

  Assume homogeneous array with 6 rows and 8 columns

imagine that a homogeneous array with 6 rows and 8 columns, is stored in row major order starting at address 20 (base ten). If each entry in the array requires only one memory cell.

  Employeeexception class whose constructor receives a string

build an Employee class with two fields, idNum and hourlyWage. The Employee constructor requires values for both fields. Upon construction, it throw an EmployeeException if the hourlyWage is less than 6.00 or over 50.00. Save the class as Employee..

  Bookstore information management system

State the possible objects in bookstore operation involving their attributes and methods.Recognize the possible use cases and actors.

  Explain the fundamental components of a distributed system

explain the fundamental components of a distributed system.

  Assembly program to find out the price of a car rental

Write down an Assembly program in order to find out the price of a car rental. The car being rented costs $45 per day and frequent renters get a $15 discount on the total bill.

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