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

  Program dealing with selection of five random cards

Generate a program which deals with the five random cards.

  What would the new tree look

The Binary Tree is one of the best ways to organize data while you need fast access. For this assignment, we will organize a list of names and perform various operations on those names.

  Handling of global ethics issue by organizations

Our textbook describes the ethics as “the principles of right and wrong which individuals utilize in order to make choices in order to guide their behaviors”.One global ethical issue is software piracy. What can the organizations such as Microsoft ..

  Why is the object-oriented database model

Why is the object-oriented database model gaining acceptance for developing applications and managing  hypermedia databases at business websites.

  Make a design flow chart or psuedocode algorithm

In either case, show the mortgage payment amount. Then, list the loan balance and interest paid for each payment over the term of the loan. On longer term loans, the list will scroll off the screen.

  What personnel implications are when setting up a wan

What personnel implications are when setting up a wan? You are hired by a firm that has offices in Peru, France, the United States, and Hungary. Your job is to coordinate a team of IT workers to connect all of individual sites into one large WAN.

  Decribe the functions of a network node manager

Explain the processes that take place during network discovery and mapping.

  Express the concept of knowledge management

How data, information and knowledge are related to the concept of knowledge management? How are they different? Please define each one: data, information, knowledge and KM.

  Changing the web-based email system

Explain an example of an email message which you could transmit to the user of this Web-based email system and that could enable you to read all of that users email.

  How each diagram relates to the solution

Your submission should include 6 to 8 pages of Visio developed UML diagrams (minimum of six different ones), hierarchy chart, and flowcharts; copy/paste into a MS Word document that also contains the pseudo code and data dictionary for the solutio..

  Carrying out the investigation

You work for the mid-size corporation that is known for its inventions that does the lot of work of copyright and patent. You are investigating an employee suspected of selling and distributing animations generated for your corporation.

  A java based program to calculate the maximum heart rate

Write down a java based program to calculate the Maximum heart rate of person based on the person age and height. Notify for the low end of the target zone (65%) and high end of the target zone (90%).

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